在css中编写不同的结构

前端之家收集整理的这篇文章主要介绍了在css中编写不同的结构前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
图片

我想编码这个图像!

一个简单的代码:(有问题)

  1. .hr{
  2. position:relative;
  3. height:100px;
  4. background : #ddd;
  5. clear both;
  6. margin-top: 100px ;
  7. }
  8. .vr{
  9. position:absolute;
  10. width:100px;
  11. height:900px;
  12. background : #000;
  13. top:-300px;
  14. z-index:-1
  15. }
  16.  
  17.  
  18. <div class='hr' style=''><div class='vr' style='left:100px;'></div><div class='vr' style='right:100px;z-index:0'></div></div>
  19. <div class='hr' style=''></div>

…………..

解决方法

你可以用这种方式使用伪元素进行破解 –
  1. .hr{
  2. position:relative;
  3. height:100px;
  4. background : #ddd;
  5. clear both;
  6. margin-top: 100px ;
  7. }
  8. .vr{
  9. position:absolute;
  10. width:100px;
  11. height:900px;
  12. background : #000;
  13. top:-300px;
  14. z-index:-1
  15. }
  16.  
  17. .bottom:after {
  18. content: '';
  19. position: absolute;
  20. top: 0px;
  21. left: 100px;
  22. width: 100px;
  23. height: 100px;
  24. background-color: black;
  25. }
  1. <div class='hr' style=''>
  2. <div class='vr' style='left:100px;'></div>
  3. <div class='vr' style='right:100px;z-index:0'></div>
  4. </div>
  5. <div class='hr bottom' style=''></div>

猜你在找的CSS相关文章