<hr> tag as an Image

浪尽此生 提交于 2019-12-25 14:48:40

问题


Id like to use a custom .png as a hr line

Here is my image:

This is the code I wrote, but it doesn't work:

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

I don't want it to repeat, Just want one in the middle of the page. If it helps in anyway I am using bootstrap.

Thanks in advance, Tom


回答1:


You just need to add

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

a simple google search can find this...

first result of google when searching how to center backgrounds http://www.w3schools.com/cssref/pr_background-position.asp




回答2:


Add no repeat property to your <hr> background's CSS.

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

or

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



回答3:


Try like this:

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



回答4:


maybe you need something like this?

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

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



来源:https://stackoverflow.com/questions/32499132/hr-tag-as-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!