What is the best way to prevent <hr> from covering a <div> in CSS?

I'm currently facing a challenge in moving an <hr> element behind my div element. I have already tried positioning, but it didn't work as expected. The <hr> is still visible through the white parts, most likely because they are transparent.

Perhaps my approach to achieving this is incorrect. You can see a working example here: Fiddle

My goal is to create a menu like this: https://i.sstatic.net/eptC7.png

Below is the CSS code I used:

.intro-text h1 {
    font-weight: 700;
    color: #ffa600;
    font-size: 22px;
    margin-bottom: 0;
}
.intro-text hr#myh {
    margin: 0;
    width: 100%;
    background-color: #ffa600;
}
.intro-text div#myimgdiv {
    margin-top: -20.5px;
    text-align: center;
}
.intro-text span {
    margin: 0 1.5vw;
}
.intro-text img {
    border-radius: 50%;
    width: 40px;
}

.make-border {
    box-shadow: 0 0 0 2px #ffa909, 0 0 0 2px #ffffff;
}

And here is the corresponding HTML code:

<div class="col-sm-12 intro-text">
    <h1>Set Room</h1>
    <hr id="myh"> 

    <div id="myimgdiv">
        <span id="step1">
            <img class="make-border" src="http://imgur.com/oq54SFb.png">
        </span>
        <span id="step2">
            <img src="http://imgur.com/oq54SFb.png"> 
        </span>
        <span id="step3">
            <img src="http://imgur.com/oq54SFb.png">
        </span>
        <span id="step4">
            <img src="http://imgur.com/oq54SFb.png">
        </span>
        <span id="step5">
            <img src="http://imgur.com/oq54SFb.png">
        </span>
    </div>
</div>

Answer №1

You have the ability to assign background colors to your elements using radial-gradient for images or color for divs.

You can also modify borders and colors to decorate the horizontal rule. Check out this example

.intro-text h1 {
  font-weight: 700;
  color: #ffa600;
  font-size: 22px;
  margin-bottom: 0;
}

.intro-text hr#myh {
  margin: 0;
  width: 100%;
  border: solid 1px;
  color: #ffa600;
}

.intro-text div#myimgdiv {
  margin-top: -20.5px;
  text-align: center;
}

.intro-text span {
  margin: 0 1.5vw;
}

.intro-text img {
  border-radius: 50%;
  width: 40px;
}

.make-border {
  box-shadow: 0 0 0 2px #ffa909;
  background: white;
}

img {
  background: radial-gradient(circle at center, white 10px, transparent 10px);
}
<div class="col-sm-12 intro-text">

  <h1>
    Customize Your Room
  </h1>

  <hr id="myh">

  <div id="myimgdiv"> <span id="step1"> <img class="make-border" src="http://imgur.com/oq54SFb.png">
</span> <span id="step2"> <img src="http://imgur.com/oq54SFb.png"> </span> <span id="step3"> <img src="http://imgur.com/oq54SFb.png"> </span> <span id="step4"> <img src="http://imgur.com/oq54SFb.png"> </span> <span id="step5"> <img src="http://imgur.com/oq54SFb.png"> </span>
  </div>
</div>

Answer №2

For your border-making class, include the following:

background-color: #f0f0f0;

(or a color that matches your page background)

Answer №3

To achieve this, you can ensure that both images have a background color that matches the light gray of your website. You can make each numbered image look like the example image provided here, with a gray background: http://imgur.com/a/J6FhC. Then, include the following CSS code:

.add-border {
background-color: #f3f5f6;
}

Answer №4

I made adjustments to the CSS code:

 .intro-text hr#myh {
     margin: 0;
     width: 100%;
     background-color: #ffa600;
 }

Changed the above code to:

.intro-text hr#myh {
    margin: 0;
    width: 100%;
    border-top: 1px solid #ffa909; // The background-color property was replaced with border-top
}

Additionally, I included a background to the following code:

.make-border {
    box-shadow: 0 0 0 2px #ffa909, 0 0 0 0px #ffffff;
    background-color: #ffffff;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I show pagination links as buttons on a gridview in ASP.NET?

When working on asp.net web forms, I encountered an issue where I was unable to display pagination links as buttons with a gray background on the grid view control. To achieve this, I needed to assign a CSS class to the pager style on the grid view in ord ...

Header element placement problem

After collaborating with fellow members of this community, we successfully developed this code. The issue at hand: Struggling to position headers below the social buttons in the center of the page after a div element. Here's the link to the Fiddle f ...

Tips for verifying the presence of a value within an array using checkboxes

My firestore database contains a collection named world with a sub-collection called languages I have developed two functions: one to retrieve all documents from the sub-collection languages, and another function to fetch every language if the userUid val ...

Adding text to a horizontal scrolling element causes the parent div to be pushed downwards

Can anyone help me understand why inserting text into one of the divs in a horizontally scrolling div causes the parent div to move downward? Looking for suggestions! @import url('https://fonts.googleapis.com/css?family=Hind:300,400,500,600,700&apo ...

Tips for toggling the visibility of a <div> element with a click event, even when there is already a click event assigned

No matter what I try, nothing seems to be working for me. I'm looking to hide the <div id="disqus_thread"> at first and then reveal it when I click on the link "commenting", after the comments have loaded. This particular link is located at the ...

picture is not properly aligned with the right side of the container

I'm struggling to align the image flush with the right border of the div without any margin or padding. I've tried various methods but none seem to work. Hoping someone can provide a solution for me. Thank you. Below is the code snippet: HTML ...

Begin one lesson, end all others

Looking for help with my expandable list menu that I created using jQuery. Here is the code snippet: $("#menu ul li ul").hide(); $("#menu ul li").click(function() { $(this).find("ul").slideToggle(); }); You can view the fully functional menu on jsFi ...

What is the best way to add a right-hand side navigation bar without blocking the scrollbar from view?

Take a look at this webpage: I am designing a website that includes a header, a footer, and a central container with left and right navigation bars surrounding a content area. However, I want the scrollbar for the content to appear on the right side of th ...

Should I use margin-top, padding-top, or top?

I often mix up padding-top, margin-top, and top. My issue arises when I need to create a space of 15px. Using margin-top: 15px seems to work, but I suspect it might be incorrect? .subtitles{ font-size:13px; font-family: "Open Sans","Helvetica Neue", ...

Customize the color of a Bootstrap btn-group

Is there a way to modify the background color of the active or selected button within a button group? <div class="btn-group" role="group" aria-label="Basic radio toggle button group"> <input type="radio" c ...

Tips for showing data from Ajax responses on an HTML page

In my code, there are two JavaScript functions: The function fetch_items is responsible for returning data in the form of stringvalue. On the other hand, the function extract_items($arr) passes values to the fetch_items function. function fetch_items ...

Issue with Aligning Text Inputs and Images in Firefox

I am really struggling with this issue and it's driving me crazy. The problem lies with an image positioned at the end of a text input, styled using CSS. Here is the code snippet: .text_input{ background:url(../images/forms/text_input_back.png) t ...

Ensure that the logo/header remains fixed at the top of the page at all

Currently, I am facing an issue with keeping my logo/header at the top of the page. I have experimented with CSS properties like position: fixed; z-index: 9999; top: 0; left: 0;, and even tried adjusting the positioning to left: 40%; in an attempt to cente ...

The border bottom effect in Hover.css is malfunctioning when used in the Opera browser

I've implemented a hover effect using hover.css that works perfectly in all browsers except Opera. Surprisingly, the effect only seems to work in Opera when I remove the following properties: -webkit-transform: perspective(1px) translateZ(0); transf ...

Display the text area when the "Yes" radio button is clicked, while it remains hidden either by default or when the "No" radio button is selected

I am currently working on an html code and I am looking for a way to use java script in order to create a text area box only when the "Yes" radio button is selected. This text area should be hidden by default or when selecting "NO". <table class="tab ...

Tips on how to show the image icon in place of the image name

Here is a code snippet for multiuploading images using Vue. Currently, the uploaded images are displayed by their file names. However, I am looking to enhance this functionality by displaying an image icon instead of the file name. If anyone knows how to ...

The JavaScript require() function appears to be malfunctioning

Why am I encountering an error when trying to import a valid node_module? <script > var Twit = require('twit'); </script> Error: Uncaught ReferenceError: require is not defined I am puzzled as to why the require() function wor ...

Is there a way to ensure that the fixed modal remains at the forefront and that its top stays in view even as the user scrolls?

Can you assist me in simplifying this code? import { LoginProps } from '@/layouts/layout.props'; import { Box, Button, Divider, Flex, FormControl, FormLabel, Heading, HStack, IconButton, Input, Link, Stack, Text, } from ...

What is the best way to position a website in the center in the provided example?

Simple question here, couldn't find it in the search so sorry if it's a repeat. How is the content on this responsive website centered? I've checked the body margins but can't seem to locate anything. Thank you for your help. ...

The Ultimate Guide to Automatically Updating JSON File URLs

I am currently working on a project where I need to retrieve data from a URL using the $.getJSON method. I am interested in finding a way to continuously update this data and replace it in the HTML without needing to manually refresh the page. Although I h ...