Phần bên trái và bên phải html

Thuộc tính CSS

left = 
auto |


=
|


9 tham gia xác định vị trí nằm ngang của phần tử được định vị. Nó không có tác dụng đối với các phần tử không được định vị

Thử nó

cú pháp

/*  values */
left: 3px;
left: 2.4em;

/* s of the width of the containing block */
left: 10%;

/* Keyword value */
left: auto;

/* Global values */
left: inherit;
left: initial;
left: revert;
left: revert-layer;
left: unset;

giá trị

left = 
auto |


=
|


0

Một

left = 
auto |


=
|


0 âm, null hoặc dương đại diện cho

  • đối với các phần tử được định vị tuyệt đối, khoảng cách đến cạnh trái của khối chứa
  • đối với các phần tử được định vị tương đối, khoảng cách mà phần tử được di chuyển sang bên phải của vị trí bình thường của nó
left = 
auto |


=
|


2

Một

left = 
auto |


=
|


2 chiều rộng của khối chứa

left = 
auto |


=
|


4

Chỉ định rằng

  • đối với các phần tử được định vị tuyệt đối, vị trí của phần tử dựa trên thuộc tính
    left = 
    auto |


    =
    |


    0, trong khi
    left = 
    auto |


    =
    |


    1 được coi là chiều rộng dựa trên nội dung;
  • đối với các phần tử được định vị tương đối, khoảng cách của phần tử từ vị trí bình thường của nó dựa trên thuộc tính
    left = 
    auto |


    =
    |


    0;
left = 
auto |


=
|


7

Chỉ định rằng giá trị giống với giá trị được tính toán từ phần tử cha của nó [có thể không phải là khối chứa nó]. Giá trị được tính toán này sau đó được xử lý như thể nó là một từ khóa

left = 
auto |


=
|


0,
left = 
auto |


=
|


2 hoặc
left = 
auto |


=
|


4

Sự mô tả

Hiệu ứng của

left = 
auto |


=
|


9 phụ thuộc vào cách phần tử được định vị [i. e. , giá trị của tài sản

  
    
      position: absolute;
      left: 20px;
      top: 20px;
    
    
      The only containing element for this div is the main window, so it
      positions itself in relation to it.
    
  

  
    
      position: relative;
      top: 0;
      right: 0;
    
    Relative position in relation to its siblings.
  

  
    
      float: right;
      position: relative;
      top: 20px;
      left: 20px;
    
    Relative to its sibling div above, but removed from flow of content.

    
      
        position: absolute;
        bottom: 10px;
        right: 20px;
      
      Absolute position inside of a parent with relative position
    

    
      
        position: absolute;
        right: 0;
        left: 0;
        top: 200px;
      
      Absolute position with both left and right declared
    
  

2]

  • Khi
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    2 được đặt thành
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    4 hoặc
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    5, thuộc tính
    left = 
    auto |


    =
    |


    9 chỉ định khoảng cách giữa lề ngoài của cạnh trái của phần tử và đường viền trong của cạnh trái của khối chứa nó. [Khối chứa là tổ tiên mà phần tử được định vị tương đối. ]
  • Khi
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    2 được đặt thành
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    8, thuộc tính
    left = 
    auto |


    =
    |


    9 chỉ định khoảng cách mà cạnh trái của phần tử được di chuyển sang phải so với vị trí bình thường của nó
  • Khi
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    2 được đặt thành
    left = 
    auto |


    =
    |


    41, thuộc tính
    left = 
    auto |


    =
    |


    9 được sử dụng để tính toán hình chữ nhật ràng buộc dính
  • Khi
    
      
        
          position: absolute;
          left: 20px;
          top: 20px;
        
        
          The only containing element for this div is the main window, so it
          positions itself in relation to it.
        
      
    
      
        
          position: relative;
          top: 0;
          right: 0;
        
        Relative position in relation to its siblings.
      
    
      
        
          float: right;
          position: relative;
          top: 20px;
          left: 20px;
        
        Relative to its sibling div above, but removed from flow of content.
    
        
          
            position: absolute;
            bottom: 10px;
            right: 20px;
          
          Absolute position inside of a parent with relative position
        
    
        
          
            position: absolute;
            right: 0;
            left: 0;
            top: 200px;
          
          Absolute position with both left and right declared
        
      
    
    
    2 được đặt thành
    left = 
    auto |


    =
    |


    44, thuộc tính
    left = 
    auto |


    =
    |


    9 không có hiệu lực

Khi cả

left = 
auto |


=
|


9 và
left = 
auto |


=
|


0 được xác định và các ràng buộc về chiều rộng không ngăn cản điều đó, phần tử sẽ kéo dài để đáp ứng cả hai. Nếu phần tử không thể kéo dài để đáp ứng cả hai, vị trí của phần tử được chỉ định quá mức. Trong trường hợp này, giá trị
left = 
auto |


=
|


9 được ưu tiên khi vùng chứa từ trái sang phải;

định nghĩa chính thức

Giá trị ban đầu

left = 
auto |


=
|


4Áp dụng cho các phần tử được định vịInheritednoPercentages tham chiếu đến chiều rộng của khối chứa Giá trị tính toánnếu được chỉ định làm độ dài, độ dài tuyệt đối tương ứng;

Chủ Đề