- 主题:弱问css如何让文字对其底部并居中?
btw:
这个div相对的参照物需要是body,即offsetParent ==body ||documentElement
【 在 shaolin (叶孤城|漫漫当爹路) 的大作中提到: 】
: absolute+width100%+text-align处理吧。
: 前提是不能有border跟padding
--
FROM 211.100.227.*
不知道是不是那个意思?
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title></title>
<style type="text/css">
#header{height:20px;width:100%;background-color:#DDDDDD;}
#footer{height:20px;width:100%;background-color:#AAAAAA;}
#content{background-color:red;width:300px;height:30%;position:relative;}
div#txt-align
{
background:yellow;
position:absolute;
bottom:0;
color:black;
width:inherit;
text-align:center;
}
</style>
<script language="javascript">
</script>
</head>
<body>
<div id="header">
Header
</div>
<div id="content">
<div id="txt-align">text at the bottom and the center</div>
</div>
<div id="footer">Footer</div>
</body>
</html>
【 在 ex2 (d2) 的大作中提到: 】
: 就是让一行文字在容器最下方[或者指定距离容器底部多少px]
: 并且文字在横向上要居中
: 弄了很久, 都不能实现, 两者好像有点排斥[应该是我撮...]
: ...................
--
FROM 208.91.115.*
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<title>无标题文档</title>
<style type="text/css">
.align-center{
height:300px;
width:300px;
background:red; /* 背景色 */
text-align:center; /* 文字等内容居中 */
border:1px solid #333333;
}
.a{width:24px;height:300px;background:green;margin:0 auto;position:relative}
.c{position:absolute;bottom:0;background:yellow;}
</style>
</head><body>
<div class="align-center"><div class="a">aaa<div class="c">ccc</div></div></div>
</body>
</html>
【 在 ex2 (d2) 的大作中提到: 】
: 就是让一行文字在容器最下方[或者指定距离容器底部多少px]
: 并且文字在横向上要居中
: 弄了很久, 都不能实现, 两者好像有点排斥[应该是我撮...]
: ...................
--
FROM 60.12.227.*