CSS之滑动

作者: 追逐_chase | 来源:发表于2018-11-20 16:38 被阅读2次
    web.jpg

    主要是利用CSS精灵图(background-position)和盒子的padding撑开宽度,类适应不同数字数的导航条

    • 不能设置宽度
     <a href="#"> 
          <span>首页</span> 
     </a> 
    
    
    image.png
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    
        <style>
          *{
              padding: 0;
              margin: 0;
          }
    
          ul {
              list-style: none;
              margin-top: 200px;
              margin-left: 200px;
          }
    
          a{
              display: inline-block;
              height: 33px;
              background: url("./images/to.png") no-repeat;
              padding-left: 15px; 
          }
          span {
              height: 33px;
              line-height: 33px;;
              display: inline-block;
              background: url("./images/to.png") no-repeat center right;
              padding-right: 15px;
              color: #ffffff;
          }
        
        </style>
    </head>
    <body>
    
        <ul>
            <li>
                <a href="#">
                    <span>这是什么观察表还不行</span>
                </a>
            </li>
        </ul>
        
    </body>
    </html>
    
    image.png

    相关文章

      网友评论

        本文标题:CSS之滑动

        本文链接:https://www.haomeiwen.com/subject/rqwopftx.html