Jump to content

Can't make hr:before tag alignment center with css

Go to solution Solved by MoeTalks,

Recommended Posts

Posted

I cannot get this hr:before tag to be align with the center sothat if a user expands or decreased the width, the box will move with it.  Using left: 25% at least shows me that the box can move independently of the hr tag.  I've tried <div> but the hr:before just disappears. I've tried flexbox and every other thing i've seen on the web.  I would prefer not to have to create an image just to separate page content.  Does anyone have any thoughts or even a better way to do this.  Photo attached and as always thanks in advance.

2024-03-15_19-25-39.thumb.png.887f2fa5f1f93eac4a623365a3757a98.png<style>
.sqs-block-horizontalrule 
  hr {
    background-color: #555;
    border: none;
    display: block;
    height: 4px;
    overflow: visible;
    position: relative;
    width: 100%;
}

hr:before {
    background-color: #8EB6DC;
    content: '';
    display: block;
    height: 8px;
width: 20%;
  left: 25%;
    position: absolute;
    top: -2px;
    z-index: 1;
}
<hr></style>

  • Replies 3
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

moecritiques.com pw 2024 go to test page. 

I've removed all CSS for the time being to test but the code for the above requested is on the test page.  Thank you in advance.

  • Solution
Posted

@paramjeet.kour08

This was hours of research and a beast but I finally found the answer.  I think I should just quit - YIKES.

This was the code I had been searching for.  I had to take bits and pieces and tweak it, but I finally got it.  Thank you anyway.

<style>
  hr {
  overflow:initial;

  &:after {
    content:'';
    width:15%;
    height:10px;
    display:block;
    background:#8EB6DC;
    top:-5px;
    margin:auto;
    position:relative;
  }
}
}
  </style>

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.