【问题标题】:<hr> tag as an Image<hr> 标签作为图像
【发布时间】:2015-09-10 18:22:53
【问题描述】:

我喜欢使用自定义 .png 作为 hr 线

这是我的图片:

这是我写的代码,但它不起作用:

hr { 
display: block;
margin-left: auto;
margin-right: auto;
height:20px;
background:url(../img/bocLine.png);
border:0;
border-color: #000;
}

我不想重复,只想在页面中间有一个。如果它有帮助,我正在使用引导程序。

提前致谢,汤姆

【问题讨论】:

标签: html twitter-bootstrap css


【解决方案1】:

你只需要添加

background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;

一个简单的谷歌搜索可以找到这个...

google 搜索如何居中背景时的第一个结果http://www.w3schools.com/cssref/pr_background-position.asp

【讨论】:

  • 工作完美,我以前从未这样做过,所以我不确定要谷歌什么,更感谢您的帮助,我想要的效果我刚刚摆脱了背景附件:已修复;
  • 谷歌你的朋友你可以使用你的问题作为搜索例如如果你搜索这个&lt;hr&gt; tag as an Image center background你会得到很多结果:p
  • 哈哈我猜谷歌是!永远不要少感谢和投票并标记为对您正确!
【解决方案2】:

试试这样:

hr { 
display: block;
margin: 0 auto;
height:20px;
background:url(../img/bocLine.png) no-repeat center top; 
border:0;
}

【讨论】:

    【解决方案3】:

    &lt;hr&gt; 背景的 CSS 中不添加重复属性。

    background-image: url(../img/bocLine.png);
    background-repeat: no-repeat;
    

    background: transparent url(../img/bocLine.png) no-repeat center center;
    

    【讨论】:

      【解决方案4】:

      也许你需要这样的东西?

      hr {
          background:url("image.png") no-repeat top center;
          height:42px;
          border:none !important;
      }
      

      https://fiddle.jshell.net/r9usqnc6/1/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-05
        • 2019-01-26
        • 1970-01-01
        • 2016-02-14
        • 2021-05-26
        • 1970-01-01
        • 2014-06-29
        • 1970-01-01
        相关资源
        最近更新 更多