Cs中的相对定位和绝对定位问题(菜鸟问题)_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:32:57
Original
1542 people have browsed it

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><style type="text/css">.parent{		width:700;	height:100;	top:5px;	left:5px;	position:relative;	background-color:#366} #duanlu{	text-align:right;	right:10px;	bottom:10pX;	position:absolute;	}</style><body><div class="parent"><strong id="duanlu">sdfsddsd</strong></div></body></html>
Copy after login


我这样写为什么页面上没有任何显示了呢....   我是在看>这本书的时候有一小段这样的代码...   求解释..... 


回复讨论(解决方案)

.parent
{
    
    width:700 px;
    height:100 px;
    top:5px;
    left:5px;
    position:relative;
    background-color:#366}

 #duanlu
{
    text-align:right;
    right:10px;
    bottom:10pX;
    position:absolute;
    }

注意单位么有写。

.parent
{
    
    width:700px;
    height:100px;
    top:5px;
    left:5px;
    position:relative;
    background-color:#366}

 #duanlu
{
    text-align:right;
    right:10px;
    bott……
++

相对定位(relative),绝对定位(absolute)简单说下。
当父级设置了相对定位,那他里面的元素如果设置了绝对定位,那么这个定位坐标是应离他最近的一个设置了相对定位的父级去坐参考,反之如果这个元素所有的父级都没有设置成相对定位,那就是以默认的body为参考,即整个窗口了。

.parent
{
   
  width:700px;
  height:100px;
  top:5px;
  left:5px;
  position:relative;
  background-color:#366}

 #duanlu
{
  text-align:right;
  right:10px;
  bottom:10pX;
  position……


dui

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template