What could be causing the no-repeat functionality to fail on these background images, and what steps can be taken to prevent the list text from overlapping with the image?

UPDATE EDIT. There is still an unresolved issue with this problem. Although setting the background to no-repeat fixed the image repetition problem, the list item text still overlaps the background image and there is an extra tick to the left. Please refer to the new screenshot for clarity.

https://i.sstatic.net/L8crt.png

Despite modifying the original code and attempting various margin and padding adjustments, I have not been able to successfully fix the positioning of the background image.

The current CSS is as follows:

ul.follow-background {
    list-style: none;
    margin: 0;
    padding: 0;
}

.follow {
    background: no-repeat left 16px; /** fixed vertical position **/
    padding: 0 0.6em 0 0;
}

.follow-background .follow a::before {
    content: '';
    list-style: none outside !important;
    vertical-align: top;
    line-height: 20px;
    margin: 0 0 0 1em;
    padding: 0 0 0 0.6em;
    top:0;
    left: 0;
    right:20px;
    bottom:0;
    overflow: hidden;
}

.follow.facebookicon {
    background-image: url('https://www.botanical-art.baeecorp.org/wp-content/uploads/facebook-icon-16x16.png')
}

.follow.flickricon {
    background-image: url('https://www.botanical-art.baeecorp.org/wp-content/uploads/fluid-flickr-logo-16x16.png');
}

.follow.linkedinicon {
    background-image: url('http://www.botanical-art.baeecorp.org/wp-content/uploads/linkedin-icon-16x16.png');
}

.follow.pinteresticon {
    background-image: url('https://www.botanical-art.baeecorp.org/wp-content/uploads/pinterest-logo-16x16.png');
}

.follow.rssicon {
    background-image: url('https://www.botanical-art.baeecorp.org/wp-content/uploads/rss-logo-blue-bullet-16x16.png');
}

.follow.twittericon {
    background-image: url('https://www.botanical-art.baeecorp.org/wp-content/uploads/twitter.gif');
}

THE HTML remains the same:

<p>Follow us on our social media connections:</p>
<ul class="follow-background">
<li class="follow facebookicon"><a href="https://www.facebook.com/baeeorg" rel="nofollow">Facebook</a></li>
<li class="follow flickricon"><a href="https://www.flickr.com/photos/baee/" rel="nofollow">Flickr Photo Albums</a></li>
<li class="follow pinteresticon"><a href="https://www.pinterest.com/baee0196/" rel="nofollow">Pinterest</a></li>
<li class="follow twittericon"><a href="https://twitter.com/BaeeArtists" rel="nofollow">Twitter</a></li>
<li class="follow rssicon"><a href="https://www.botanical-art.baeecorp.org/news/" rel="nofollow">News Announcements (subscribe to get our latest posts)</a></li>
</ul>

END EDIT UPDATE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Answer №1

Responding to your updated query, here is a fresh response. While your current approach would work by including some left padding to your anchor and applying a list-style:none; to your .follow class, I have devised a new solution that can be utilized in the future.

.follow {
  list-style:none;
  position:relative;
}
.follow:before {
  content:'';
  position:relative;
  display:inline-block;
  width:20px;
  height:20px;
  top:7px;
  background-repeat:no-repeat;
}
.facebookicon:before{
  background-image:url('https://www.botanical-art.baeecorp.org/wp-content/uploads/facebook-icon-16x16.png');
}
.flickricon:before {
   background-image:url('https://www.botanical-art.baeecorp.org/wp-content/uploads/fluid-flickr-logo-16x16.png');
}
.pinteresticon:before {
   background-image:url('https://www.botanical-art.baeecorp.org/wp-content/uploads/pinterest-logo-16x16.png');
}
.twittericon:before {
   background-image:url('https://www.botanical-art.baeecorp.org/wp-content/uploads/twitter.gif');
}
.rssicon:before {
   background-image:url('https://www.botanical-art.baeecorp.org/wp-content/uploads/rss-logo-blue-bullet-16x16.png');
}
<ul class='follow-background'>
  <li class='follow facebookicon'><a href='#' title='' rel='nofollow'>Facebook</a></li>
   <li class='follow flickricon'><a href='#' title='' rel='nofollow'>Flickr Photo Albums</a></li>
   <li class='follow pinteresticon'><a href='#' title='' rel='nofollow'>Pinterest</a></li>
   <li class='follow twittericon'><a href='#' title='' rel='nofollow'>Twitter</a></li>
   <li class='follow rssicon'><a href='#' title='' rel='nofollow'>News Announcments ( subscribe to get our latest posts ) </a></li>
  
</ul>

Maintained the previous answer for relevance

You have added background: no-repeat left 7px; to the container & Psuedo class but as the background is defined on .follow, it won't inherit the no-repeat property so basically add

.follow {
background-repeat:no-repeat;
}

Answer №2

When you apply the rule to the ::before pseudo selector, you are targeting a separate element that acts as the first child of its parent.

CSS utilizes ::before to generate a pseudo-element as the initial child of the chosen element. This technique is commonly employed to embellish an element with cosmetic content through the content property. By default, it is displayed inline.

Explore MDN's Documentation on ::before

The background rule should be added to the .follow class. Furthermore, you might want to look into incorporating list-style-image.

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

What is the best way to split a semicircular border radius in two equal parts?

Is there a way to halve the yellow line or remove it from above the red box, while keeping it below? Can this be achieved using just HTML and CSS, or is JavaScript necessary? * { margin: 0; padding: 0; box-sizing: border-box; } body { height: 1 ...

Add an arrow or triangle at the tip of the line

I am currently working on recreating the design of lines with an arrow or triangle at the end side of an Input form. The inspiration for this comes from an old flash application that is now being converted to HTML5: https://i.sstatic.net/OCpif.jpg So far, ...

What is the best way to style these CSS elements within the stylesheet?

I'm currently working on customizing a navigation menu in DotNetNuke. Although my question primarily relates to CSS syntax. Can someone please provide guidance on how to style a class that resembles the following? <tr class="mi mi0-0 id58 first"& ...

What could be causing the span class data to not be retrieved by the getText method

Looking to retrieve the value of a span class called 'spacer-right big project-card-measure-secondary-info' <span class="spacer-right big project-card-measure-secondary-info">1</span> snippet of code: browser.waitForEl ...

What is the best way to keep a bootstrap navbar fixed at the top when scrolling? (It's a bit tricky)

Check out this image of my website header. HERE Is there a way to achieve a smooth scrolling effect for the blue navbar as I scroll down the page? (Specifically just the navbar, excluding the logo and social media elements). Using position:fixed; does ...

VUE component disregarding CSS styles

Check out my awesome VUE component below: <template> <div> <div class="bottom-footer"> {{msg}} </div> </div> </template> <script> export default { ...

What are some effective strategies for incorporating multiple Themes into an AngularJS project?

Currently, I am in the process of working on a project that involves utilizing AngularJS, UI Bootstrap, and Sass. The next step is to incorporate different themes that can be selected by the user. While I have successfully implemented the ability to apply ...

Enable access to the child of Lages and apply CSS to disable it

My current code looks something like this: <label for="billing:postcode" class="required"><em>*</em>Zip/Postal Code</label> I am looking to hide the <em> element from displaying using CSS. How can I achieve this with the dis ...

Admin template system for CodeIgniter

In order to give the Administrator the ability to customize the Admin Dashboard Layout and provide an option for them to upload their own layouts or "Premium" layouts, I need to implement a solution. I have considered one approach: Utilizing CSS (allowin ...

Choosing a color while hovering over the navigation bar

I'm trying to modify the color of my navigation bar when hovering over it with the mouse. Currently, it's black but I want it to change to a light grey or white color. What am I missing here? HTML: <!DOCTYPE html> <html> <head ...

Displaying overlay when sidebar menu is expanded

I am working on creating a smooth overlay transition for when the sidebar menu opens and closes. When the overlay is clicked, I want the menu to close. This is what I have so far: $(document).ready(function() { $('#menu-toggle').click(fun ...

Strategies for successfully passing and showcasing the result of a calculation on a fresh view or component within Angular

I have developed a basic calculator application with two main components: Calculator and Result. The Angular router is used to navigate between these components. Now, I am looking for a way to dynamically display the calculation result from the Calculator ...

Optimizing Bootstrap popover responsiveness for elements with excessive length to ensure a smooth display experience

I am currently working on creating a popover that remains in position when hovered over, specifically for elements that are too large to fit on the screen. However, I am facing some issues with my current implementation: <template> <div class ...

Create a PDF on-the-fly by leveraging Vuejs to dynamically pull data and design elements

Is it possible to create a form that captures name, expiry date, and picture, and upon submission generates a PDF document with the provided details? The PDF should be based on a design created by me and have the input data displayed in a specific location ...

Issue of delayed loading of CSS in Vue.js application

My vue PWA is experiencing slow loading of CSS when using Vue Bootstrap and Buefy. I attempted to use V cloak, but it only hides components milliseconds after the raw HTML is briefly displayed without any CSS applied. I am looking for a method to display ...

Is there a way to postpone the mouseover event for vertical tabs?

While this may seem like a simple question to some, my programming skills are not quite up to par. I am seeking help from someone who can assist me. My goal is to delay the mouseover event on vertical tabs so that users can jump directly from tab 1 to ta ...

Issue with Jquery's .addClass and .removeClass functions

I'm having trouble implementing a dynamic menu on my webpage using jQuery. I've tried writing the code myself but it doesn't seem to be working as expected. The structure involves three classes: .dead, which sets display: none; in CSS, .hea ...

If the width is divisible by a certain value

I have a question regarding the width of my element that I want to divide by 90. If this width is a multiple of 90, I set the width of the element. If not, I move on to the next. For example, when the window width is 1000px and the element is at full widt ...

Struggling to insert a high-quality image into inline divs of exactly 33.3333% width

After creating 3 inline divs, each taking up 33.333% of their parent width, I encountered an issue while trying to insert images into them. Whenever the image exceeds the 33.333% width of the div, it overflows outside the container. My goal is to make the ...

Tips on how to update the styling of an active link

http://jsfiddle.net/G8djC/2/ Looking to create a tabbed area where content changes based on the tab clicked. The Javascript function switches the link class to active upon clicking. However, struggling to change the color of the active tab beyond the firs ...