Compartilhar via


left property

Sets or retrieves the position of the object relative to the left edge of the next positioned object in the document hierarchy.

 

Syntax

Integer value = object.put_left(Variant v);Integer value = object.get_left(Variant* sPosition);

Property values

Type: VARIANT

auto (auto)

Default. Default position, according to the regular HTML layout of the page.

length (length)

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.

percentage (percentage)

Integer, followed by a percent sign (%). The value is a percentage of the width of the parent object.

String format

<length> | <percentage> | auto

CSS information

Applies To All elements
Media visual
Inherited no
Initial Value auto

Standards information

Remarks

You should use the IHTMLStyle::left attribute only when the IHTMLStyle::position attribute is set; otherwise, the value of the IHTMLStyle::left attribute is ignored.

Because the value of the IHTMLStyle::left property is a string, you cannot use the property in script to calculate the position of the object in the document; instead, you should use the IHTMLStyle::pixelLeft property or the IHTMLStyle::posLeft property.

Because the value of the IHTMLStyle::left property is a string, you cannot use the property to calculate the position of the object in the document.

Because the value of the IHTMLStyle::left property is a string, you cannot use the property in script to calculate the position of the object in the document; instead, you should use the IHTMLStyle::pixelLeft property or the IHTMLStyle::posLeft property.

For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Examples

The following example uses the IHTMLStyle::left property to change the position of the blue div. In the example below, there are four div with absolute positioning. The blue div is positioned 250 pixels from the left.

Code example: http://samples.msdn.microsoft.com/workshop/samples/css/positioning/positioning.html

#blue{
   height: 150px;
   width: 150px;
   background-color: #00A4EF;
   position: absolute;
   left: 250px;
}

This example uses inline scripting to change the position of two images when an HTMLFrameSiteEvents::onclick event occurs.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/left_s.htm

<!DOCTYPE html>
<html>
<head>
  <title>left</title>
</head>

<body>
  <p>
    These images are aligned with the left side of this window using
    absolute positioning and left positioning.
  </p>
  <img id="cone" src="http://samples.msdn.microsoft.com/Workshop/graphics/cone.jpg" style="position: absolute" height="80" width="80" border="0" alt="cone">
  <img id="sphere" src="http://samples.msdn.microsoft.com/Workshop/graphics/sphere.jpg" style="position: absolute; left: 50px" height="80" width="80" border="0" alt="sphere">
  <div style="position: absolute; top: 250px; left: 7px;">
    <button onclick="cone.style.left='100px'; sphere.style.left='200px'">Move Over</button>
    <button onclick="cone.style.left=''; sphere.style.left='50px'">Move Back</button>
  </div>
</body>
</html>

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll