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

  • SEARCH
  • Home
  • 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 8019893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:31:45+00:00 2026-06-04T21:31:45+00:00

I am wanting to construct navigation items from three (background) images, with the first

  • 0

I am wanting to construct navigation items from three (background) images, with the first and last a fixed width, and the central a variable width, depending on the width of the text in the nav item. I have been led to believe that using the pseudo elements before and after would be the best method. When I try this though, the main (central) background image for the nav item is overlapping with the before and after background images.

You can see what I mean on this page.

Here is the CSS:

.box {
   background-image: url(nav/images/nav_02.png);
   background-repeat: repeat;
   height:20px;
   position: absolute;
   padding: 10px 13px;
}


.box:before {
    left: 0;
    background-image: url(nav/images/nav_01.png);
}

.box:after {
    right: 0;
    background-image: url(nav/images/nav_03.png);
}

.box:before,
.box:after {
    content: ' ';
    width: 13px;
    height:40px;
    position: absolute;
    top: 0;
    background-repeat: no-repeat
}

And the HTML:

<div class="box">here is some text</div>

Can I use background-images in this way using pseudo elements?

Thanks,

Nick

  • 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-04T21:31:47+00:00Added an answer on June 4, 2026 at 9:31 pm

    Yes, but you will have to use left and right attributes for moving the pseudo elements in the right position. padding is not correct for the main box to position. Better use margin.

    .box {
        background-repeat-x: repeat;
        background-image: url(nav/images/nav_02.png);
        background-repeat: repeat;
        height: 40px;
        position: absolute;
        margin: 0 13px;
        line-height: 40px;
    }
    
    .box:before, .box:after {
        content: ' ';
        display:block;
        width: 13px;
        height: 40px;
        position: absolute;
        top: 0;
        background-repeat: no-repeat;
    }
    
    .box:before {
        left: -13px;
        background-image: url(nav/images/nav_01.png);
    }
    
    .box:after {
        right: -13px;
        background-image: url(nav/images/nav_03.png);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to construct an object from within a generic method. This object
Im currently wanting to construct a table type of layout for JPanels. I found
Wanting to make sure I'm using classes properly. The main script accepts this from
Hi I am wanting to create a base class to inherit from but I
So I'm wanting to implement the TinyMce helper. I've followed instructions from the cakephp
Wanting to integrate aspects of SharePoint into an existing website - rather than integrating
Im wanting to to display the number of pixels a user has scrolled in
I was wanting to find out if it is possible using the Facebook API
I am wanting to build a cross-platform mobile app for iOS and android devices.
I'm wanting to do something like this: priority_queue< pair<int, int>, vector<int>, greater<int> > Q;

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.