Incorporating a recurring image beneath a navigation menu

I'm attempting to recreate a header that has a similar appearance to the following:

https://i.stack.imgur.com/uVXs3.png

However, I am facing challenges in generating the repeating diamond design beneath the black bar. The diamond pattern resembles this:

https://i.stack.imgur.com/bisH4.png

Below is the current HTML and CSS code I have written for this test version:

    figure {
      background: black;
      border-radius: 3px;
      height: 50px;
      margin: 0px;
    }
    html {
      background-color: grey;
      width: 1212px;
      height: 1476px;
      margin: auto;
    }
    img {
      border-radius: 100%;
      position: relative;
      vertical-align: middle;
      left: 50px;
      bottom: 30px;
    }
    figcaption {
      display: inline-block;
      vertical-align: middle;
    }
    li {
      display: inline-block;
      text-decoration: none;
      overflow: hidden;
      margin-bottom: 50px;
    }
    a {
      list-style: none;
      text-decoration: none;
      text-align: center;
      color: white;
    }
    ul:first-child {
      float: left;
      margin-left: 100px;
    }
    ul:last-child {
      float: right;
      margin-left: 550px;
    }
    div {
      background-color: blue;
      width: 100%;
      height: 70px;
    }
<div></div>
<figure>
  <img width="100" height="100" src="http://i.imgur.com/HiCMdId.png" />
  <figcaption>
    <ul>
      <li>
        <a href="">test</a>
        <a href="">test</a>
      </li>
    </ul>
    <ul>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
    </ul>
  </figcaption>
</figure>

Answer №1

I recommend setting the image as the background of a div that covers the entire width of the navigation bar. You can then eliminate the image source from the HTML code.

Here is an example of how your CSS should look:

menu {
   background-image: url('http://i.imgur.com/HiCMdId.png');
   background-repeat: repeat-x;
   width: 100%;
}

Answer №2

Here is my solution using the ::after pseudo-element. Keep in mind that if you have multiple figure elements on your page, they will all inherit this background unless you specifically override the styles for each one.

figure {
  background: black;
  border-radius: 3px;
  height: 50px;
  margin: 0px;
  position: relative;
}
figure::after {
  content: ' s';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: url(https://i.stack.imgur.com/bisH4.png) repeat-x 0 0;
  z-index: -1;
  display: block;
  color: transparent;
  background-size: 10px 10px;
}
html {
  background-color: grey;
  width: 1212px;
  height: 1476px;
  margin: auto;
}
img {
  border-radius: 100%;
  position: relative;
  vertical-align: middle;
  left: 50px;
  bottom: 30px;
}
figcaption {
  display: inline-block;
  vertical-align: middle;
}
li {
  display: inline-block;
  text-decoration: none;
  overflow: hidden;
  margin-bottom: 50px;
}
a {
  list-style: none;
  text-decoration: none;
  text-align: center;
  color: white;
}
ul:first-child {
  float: left;
  margin-left: 100px;
}
ul:last-child {
  float: right;
  margin-left: 550px;
}
div {
  background-color: blue;
  width: 100%;
  height: 70px;
}
<div></div>
<figure>
  <img width="100" height="100" src="http://i.imgur.com/HiCMdId.png" />
  <figcaption>
    <ul>
      <li>
        <a href="">test</a>
        <a href="">test</a>
      </li>
    </ul>
    <ul>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
      <li><a href="">test</a>
      </li>
    </ul>

  </figcaption>
</figure>

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

Storing user input from Vue.js in a JavaScript array for future use

Utilizing vue.js <template> <input id="email" v-model="email" type="text" placeholder="Email"> <input id="name" v-model="name" type="text" placeholder=" ...

Unlocking the power of python with web2py by tapping into html form values

I'm working on a project using web2py and need to incorporate ajax/javascript with a form. Currently, when a user selects an option in the departure box, the arrival box appears. However, I'm unsure of how to filter the list of arrival options ba ...

:after pseudo-element along with HTML tags

I have recently designed a basic webpage in an attempt to simulate ajax using CSS. In order to achieve this, I aimed to create hidden radio buttons with visible labels, and load an external CSS file when the user clicks on a label. However, I encountered o ...

Is it possible to make the info box centered and adjust everything to seamlessly fit on all screen sizes?

Is there a way to create a centered info box that stretches to fit any screen size? ...

Sending values from multiple input fields created in PHP using AJAX can be done by following these steps

https://i.sstatic.net/GKcRc.png Within this snippet, there is a portion of a form that consists of 4 different fields/divs like the one shown. I am struggling to figure out how to send the values of these input fields to PHP using AJAX. I apologize if ...

Why does the Hamburger Menu shift my website's logo when it opens?

I'm in the process of implementing a hamburger menu on my website. My attempts have involved adjusting the positioning of both the #logo and .topnav elements. Code Snippet source function myFunction() { var x = document.getElementById("myTopn ...

Assigning a class to every alternate item

Currently, I am in the process of compiling a list of products. To enhance the layout, I would like to assign a specific class to every other element. This class could be :before, :after, or simply .My-clas <div class="product-single"></div> ...

What is the best approach to repurpose a component when small adjustments are needed?

Can a customized slider component be created in React that can be reused with slight variations? For example, having the second one include a 13% field. View image description here ...

Why isn't the show/hide feature in Jquery functioning properly?

I have a div that needs to be displayed after hovering over another element. These elements are not within the same div. The popup info should appear when an icon with the class .option_36_124 is hovered over. $(".option_36_124").hover(function(){ $(& ...

Skip nodes in Polymer 1.0 by using ExcludeLocalNames

I recently attempted to transition from Polymer version 0.5 to 1.0 and came across a particular question: Is there a way to exclude certain nodes inside a paper-menu? In the previous version (0.5), you could use the attribute excludedLocalNames to achieve ...

Animate the transition effect as soon as the block is displayed

Looking to create a smooth page transition using CSS changes with the help of Javascript (jQuery). Initially, one of the pages is set to display none. page1 = $('.page1'); page2 = $('.page2'); page1.removeClass('animate').cs ...

Scroll bar displayed on a non-editable text box

The TextArea is currently set to readonly mode using "ng-readonly," which is causing the scrollbar-thumb not to appear. It's important to note that I am not utilizing webkit in this scenario. Below is the HTML code being used: <textarea dataitemfq ...

The bootstrap code I wrote runs smoothly on Codeply's online compiler, but unfortunately it's not functioning properly in VS code

<nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="">OurCoolBrand</a> <button class="navbar-toggler" type="button&quo ...

Show the json data on a PHP table

I've been attempting to showcase JSON content in a PHP table, but I keep encountering errors. It seems like there are some syntax issues that I can't quite pinpoint. Any suggestions on what needs to be modified? PS. I'm using the Slim frame ...

Bypassing CSS rules for elements not present in the DOM

In case an element is absent from the DOM, I want to include margin space. Conversely, if the element is present, no margin space should be added. I have experimented with CSS for this purpose: A - To ensure there is no margin-top if the H2 title is displ ...

Obtaining numerous data points in a multi-select element within HTML

Struggling with determining the values of multiple <select> tags in an HTML file simultaneously? function knowAllValues(){ var color_element = document.getElementById("color"); var size_element = document.getElementById("size"); ...

Pass the identical event to multiple functions in Angular 2

On my homepage, there is a search form with an input box and select dropdown for users to search for other users by location or using html5 geolocation. When a user visits the page for the first time, they are prompted to allow the app to access their loca ...

Click outside of this popup to dismiss it

I have been struggling to figure out how to make this popup close when clicking outside of it. Currently, it only closes when clicked directly on it. Your assistance in this matter is greatly appreciated. Here is the HTML code: <h2>Popup</h2> ...

Is there a way to gather information from a web service and neatly display it within an HTML table?

Is it possible to fetch a JSON array from a web service and save it in a variable? Consider the following table structure: <table id="myTable" border="1"></table> The table is populated using the code below: // JSON array var myData = metho ...

Finding the main directory in JavaScript: a step-by-step guide

My website uses mod_rewrite to reformat the URLs like this: The issue arises when making AJAX calls to a file: I want to access login.php from the root without specifying the full URL or using the "../" method due to varying folder levels. So, I need a ...