首页 > 开发 > CSS > 正文

CSS教程:DIV底部放置文字

2024-07-11 08:20:58
字体:
来源:转载
供稿:网友

  css对文字的布局上没有靠容器底部对齐的参数,目前使用的一个不错的方法也比较好.就是用position属性来解决,看下面的代码,用position的相对和绝对定位功能也轻松的实现了,文字靠近div低部对齐,并且靠近的距离还可以精确到像素,自己可以调节,是不是很不错呢?

<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
#txt{ 

 height:300px;
 width:300px;
 border:1px solid #333333;
 text-align:center;
 position:relative 

}
#txt p{
 position:absolute;
 bottom:0px;
 padding:0px;
 margin:0px
}
</style>
</head> 
<body>
<div id=txt>
<p>aadsad</p>
</div>
</body>
</html>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表