Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:58:47+00:00 2026-06-10T00:58:47+00:00

I am trying to add two classes to one element with two different background

  • 0

I am trying to add two classes to one element with two different background images positioned on its different space. But when I apply another class it is overriding first class background image. See below

<li class="first">

li.first {background:url(images/first.png)no-repeat center top}
li.second{background:url(images/second.png)no-repeat right center}

So I want to merge both background when apply both class on li element like

<li class="first second">

Is there any way to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:58:49+00:00Added an answer on June 10, 2026 at 12:58 am

    I can think of two ways.

    You could add the second background not to the element itself, but to a pseudo-element absolutely positioned such that it fully covers the li. However, if you wish to do this for more than three classes & backgrounds, then this method doesn’t work as you can only have two pseudo-elements (:before and :after).

    Or you could simply add the first background to the second class as well.

    DEMOS

    In both cases, the HTML would be something like:

    <li class="first second"></li>
    

    The relevant CSS in the first case:

    li { 
        background-repeat: no-repeat;
        background-size: 50%;
    }
    .first {
        background-image: linear-gradient(rgba(102,37,93,.95) 50%, transparent 50%);
        background-position: 50% 0;
    }
    .second {
        position: relative;
    }
    .second:after {
        position: absolute;
        top: 0; right: 0; bottom: 0; left: 0;
        background-image: radial-gradient(rgba(255,255,255,.2), rgba(255,0,0,.9));
        background-position: 100% 50%;
        background-repeat: no-repeat;
        background-size: 50%;
        content: '';
    }
    

    … and in the second case:

    li { 
        background-repeat: no-repeat;
        background-size: 50%;
    }
    .first {
        background-image: linear-gradient(rgba(102,37,93,.95) 50%, transparent 50%);
        background-position: 50% 0;
    }
    .second {
        background-image: radial-gradient(rgba(255,255,255,.2), rgba(255,0,0,.9)), 
            linear-gradient(rgba(102,37,93,.95) 50%, transparent 50%);
        background-position: 100% 50%, 50% 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add two decimal values but the returned sum is pure
I am trying to do this List<String> stringList = new ArrayList<String>(); stringList.add(one); stringList.add(two); stringList.add(three);
I'm trying to do the following, define two classes whose instances mutually reference one
I'm trying to provide two classes to my users - one that is read-only
I am basically trying to add two view controllers to one controller. I created
I'm trying to add two object that they are in the same class. In
I'm trying to add two inputs to a QTCaptureSession in the following: mainSession =
I am trying to add two larger binary numbers (i.e. number of bits are
I am trying to add two values in a byte array. This is my
We have a situation where we are trying to add two UITableViews inside a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.