CSS fake HR with background image

I want to have an HR-shaped image. 2 pixel gif file.
I was looking for an HR tag style, but there are too many browser issues.

It uses a 2px high div with an image like bg, but in IE6 there is an add-on that I cannot get rid of.
Any suggestions are welcome!

CSS

.hr {
    margin: 0; padding: 0;
    height: 2px;
    background-image: url('images/help-hr.gif');
    background-repeat: repeat-x;
    background-color: green; /* just to see the padding in IE6 */
}

HTML:

<p>sky</p>
<div class="hr"></div>
<p>grass</p>
+3
source share
2 answers

Add overflow: hidden;

.hr {
    margin: 0; padding: 0;    
    height: 2px;    
    background-image: url('images/help-hr.gif');
    background-repeat: repeat-x;
    background-color: green; /* just to see the padding in IE6 */

    overflow:hidden;
}
+2
source

I do not know the answer to the IE6 question that you are dealing with, but I had the same problem with using hrand found a solution that worked for me:

hr {
  background-color: #ccc;
  border-width: 0;
  color: #ccc;
  height: 2px;
  line-height: 0;
  margin: -.5em 10px 1.8571em 10px;
  page-break-after: always;
  text-align: center;
  width: 80%;
}

hr:after {
  content: "\a7\a7";
  font-size: 1.25em;
}
0
source

Source: https://habr.com/ru/post/1767761/


All Articles