Tips for inserting an image within a horizontal list of items

Struggling to find a solution here. I have a menu with a unique bar design between list elements, featuring breaks at the top and bottom.

I attempted to use li:after in the CSS to insert an image, but encountered issues with padding and margin. Below is the embedded CSS and HTML code (Bootstrap framework is being used). Any suggestions on how to make these bars function correctly?

Screenshot:

(Please disregard the red color from illustrator).

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


    #reviews .review-actions {
        text-align: center;
        z-index: 2;
        padding-top: 1px;
      }
      #reviews nav {
        display:inline-block;
        margin:0 auto;
      }
      #reviews nav ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }
      #reviews nav ul li{
        display: inline;
        margin: 0;
        float: left;
        padding: 10px;
        background-color: #fff;
        font-size:1.2em;
      }
      /*#reviews nav ul li:after{
        content: url('./img/menu-splitter.png');
      }*/
      #reviews nav ul > li:first-child {
        border-top-left-radius: .5em;
        border-bottom-left-radius: .5em;
        border: 1px solid #ccd0d0;
        border-right: none;
      }
      #reviews nav ul > li:nth-child(2){
        border: 1px solid #ccd0d0;
        border-right: none;
        border-left: none;
      }
      #reviews nav ul > li:last-child {
        border-top-right-radius: .5em;
        border-bottom-right-radius: .5em;
        border: 1px solid #ccd0d0;
        border-left: none;
      }
      #reviews nav ul li a{
    
      }
    <section id='reviews'>
        <!-- Navigation -->
        <div class="review-actions">
          <nav>
            <ul>
              <li><a href='#'>The App</a></li>
              <li><a href='#'>Our Service</a></li>
              <li><a href='#'>Surprises</a></li>
            </ul>
          </nav>
        </div>
      </section>

Answer №1

One way to customize the appearance of your li element is by setting the background directly within the li tag. Here is an example of how you can achieve this:

#reviews .review-actions {
        text-align: center;
        z-index: 2;
        padding-top: 1px;
      }
      #reviews nav {
        display:inline-block;
        margin:0 auto;
      }
      #reviews nav ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }
      #reviews nav ul li{
        display: inline;
        margin: 0;
        float: left;
        padding: 10px;
        background-color: #fff;
        font-size:1.2em;
      }
      /*#reviews nav ul li:after{
        content: url('./img/menu-splitter.png');
      }*/
      #reviews nav ul > li:first-child {
        border-top-left-radius: .5em;
        border-bottom-left-radius: .5em;
        border: 1px solid #ccd0d0;
        border-right: none;
      }
      #reviews nav ul > li:nth-child(2){
        border: 1px solid #ccd0d0;
        border-right: none;
        border-left: none;
      }
      #reviews nav ul > li:last-child {
        border-top-right-radius: .5em;
        border-bottom-right-radius: .5em;
        border: 1px solid #ccd0d0;
        border-left: none;
      }
      #reviews nav ul li a{
    
      }
      li:nth-last-child(n+2) {
           background-image: linear-gradient(blue, blue);
           background-size: 2px 90%;
           background-repeat: no-repeat;
           background-position: right center;
      }
<section id='reviews'>
        <!-- Navigation -->
        <div class="review-actions">
          <nav>
            <ul>
              <li><a href='#'>The App</a></li>
              <li><a href='#'>Our Service</a></li>
              <li><a href='#'>Surprises</a></li>
            </ul>
          </nav>
        </div>
      </section>

Answer №2

To create a faux border effect, one strategy is to apply 4 single-pixel-width box-shadows around the <ul>, and then add an actual border to the <ul> matching the color of the <li> background:

      #reviews .review-actions {
        text-align: center;
        z-index: 2;
        padding-top: 1px;
      }

      #reviews nav {
        display:inline-block;
        margin:0 auto;
      }

      #reviews nav ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 6px solid #ffffff;
        box-shadow: 1px 1px #ccd0d0, -1px 1px #ccd0d0, -1px -1px #ccd0d0, 1px -1px #ccd0d0;
        border-radius: .5em;
      }

      #reviews nav ul li{
        display: inline;
        margin: 0;
        float: left;
        padding: 10px;
        background-color: #fff;
        font-size:1.2em;
        border-left: 1px solid #ccd0d0;
      }

      #reviews nav ul > li:first-child {
        border-left: none;
      }
      <section id='reviews'>
        <!-- Navigation -->
        <div class="review-actions">
          <nav>
            <ul>
              <li><a href='#'>The App</a></li>
              <li><a href='#'>Our Service</a></li>
              <li><a href='#'>Surprises</a></li>
            </ul>
          </nav>
        </div>
      </section>

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

Jquery Menu featuring subitems aligned to the right

I am experiencing an issue with my drop-down menu in ie6. The subitems menus are shifted to the right, rendering the menu useless. Here is the HTML code: <div id="navigation"> <a href="<?php echo base_url();?>" class="singl ...

"Utilizing JQuery to enhance task management by implementing a delete function

I need help figuring out how to create a function that can delete tasks from my todo list. Currently, each task has its own remove button, but I want to implement a single remove button at the bottom that removes checked or crossed out tasks. Any suggestio ...

Do not show empty pages in Mpdf display

I utilized Mpdf to generate a three-page PDF document. The first and third pages consistently contain data, but the presence of data on the second page varies. I prefer not to display the second page if it is empty. Here's the code structure: html = ...

Using JQuery with special characters in attributes

Within my jQuery script, I am required to dynamically translate certain content. As a part of this function, I have the following code: $('#password').attr('placeholder', 'Contrase&ntilde;a'); In this code snippet, I att ...

Switching Tabs When a Button is Clicked

I am currently using a guide from the link provided to learn how to create tabs: http://www.w3schools.com/howto/howto_js_tabs.asp. function openTab(evt, tabName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClass ...

Display a custom toast from a list using Bootstrap 5

I've been utilizing the toast feature from Bootstrap, and it works perfectly when displaying a single toast. However, I encountered an issue when trying to display a specific toast, like an error toast, from a list of predefined toasts. It ended up sh ...

Customizing the style of react-select is essential for creating a unique and visually appealing user experience

I am looking to maintain the visual style of my input fields to match that of a react-select component. I have been advised to use styled-components, yet I am uncertain about which styles need to be adjusted in order to achieve the desired outcome. Ideally ...

Is it possible to use an :after background-image to layer on top of the following element?

Seeking assistance on adding an image as a :after element to a navigation bar. The goal is for the image to cover the top portion of the next section according to the design. I have set the :after element as position: absolute with a top: 100%, but it app ...

Prevent Scrolling of Body Content within a Specified Div

In my current situation, I am dealing with a large number of divs (over 300) that are being used as part of an interactive background. The issue arises when viewing the page on mobile versus desktop – there are too many divs on desktop, causing excessive ...

Issue with display of Favicon in Google Chrome browser

My favicon is not appearing on my Chrome tab, even though I've checked multiple articles and confirmed that the code is correct. It does show up in Firefox, so I'm confused as to why it's not working in Chrome. I've cleared my cache and ...

How can we stop the constant fluctuation of the last number on a number input field with a maxLength restriction

In my ReactJS code, I have an input field that looks like this: <input type="number" onKeyPress={handleKeyPress} maxLength={3} min="0" max="999" step=".1" onPaste={handlePaste} /> Below are the functions associated w ...

Swipe horizontally on mobile devices with text scrolling

I stumbled upon a workaround online that effectively allows for horizontal scrolling on mobile devices. <div style="max-width: 1024px; margin: auto; "> <ul style="white-space: nowrap; overflow-y: hidden; overflow-x: scroll; -webkit-overflow-sc ...

Tips for showcasing a drop-down menu using Jquery

I am currently utilizing jQuery to showcase a drop-down menu. It is successfully working for a single menu and displaying the appropriate drop-down. However, when I attempt to use more than one menu, it displays all of the drop-down menus simultaneously. I ...

Encountering issues with accessing image files located in the public folder of my Next.js project - Receiving a 404 Error message

I am currently facing an issue with my Next.js project where I am unable to use image files from the public folder. Despite checking that the file paths, names, and extensions are correct, as well as ensuring my configurations are accurate, I keep encounte ...

Implementing ngClass with a dynamic ID in the URL condition

I am attempting to create an ngClass condition that adds an active class to a list element. Specifically, I want it to work for both the URLs '/companies' and '/company/:id'. The issue I am facing is that the current setup does not fun ...

Highlighting text in React using hover effects on list elements

Imagine having HTML / JSX structured like this: <ul> <li>First point in list</li> <li>Second point in list</li> </ul> and the goal is to highlight a contiguous range that spans multiple list items: <ul> < ...

Is it possible to configure mui v5 to display class names without the css-xxx prefix?

Working with mui has truly been a delightful experience. Each developer seems to have their own unique approach when it comes to styling and layout in react. The flexibility provided by mui must present quite the challenge for library developers. In custo ...

The hyperlink for making phone calls appears twice on an Android phone

When you click on the number, it will be displayed twice in the phone screen like this... 12345678910,12345678910 ...instead of just once... 12345678910 Take a look at the code snippet below: {#if order.salesRep} <div class="info"> ...

Disable button with Checkbox Javascript functionality

In my PHP code, I have an array of users that I pass to the view (in Laravel) and use a foreach loop to display all users in a table. Everything is working fine so far. However, I want to make a "send" button visible when a checkbox is clicked, instead of ...

Utilizing JavaScript Callbacks in HTML Image Tags

Currently I am working on a small application and looking to include a YouTube section. I have come across a method for obtaining the user's YouTube icon: This is included in the head section of my code: <script type="text/javascript" src="http:/ ...