如何用CSS让文字居于div的底部

               

转载于 http://blog.csdn.net/aigochina/article/details/19339109

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  2. "http://www.w3.org/TR/html4/loose.dtd">  
  3. <html>  
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  6. <title>无标题文档</title>  
  7. <style type="text/css">  
  8. #txt{  
  9.   
  10.  height:300px;  
  11.  width:300px;  
  12.  border:1px solid #333333;  
  13.  text-align:center;  
  14.  position:relative  
  15.   
  16. }  
  17. #txt p{  
  18.  position:absolute;  
  19.  bottom:0px;  
  20.  padding:0px;  
  21.  margin:0px  
  22. }  
  23. </style>  
  24. </head>  
  25.   
  26. <body>  
  27. <div id=txt>  
  28. <p>aadsad</p>  
  29. </div>  
  30. </body>  
  31. </html>  

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

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/qq_43668118/article/details/86543115