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 8560821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:21:52+00:00 2026-06-11T16:21:52+00:00

Imagine 4 boxes side by side (divs). These are a menu and when one

  • 0

Imagine 4 boxes side by side (divs). These are a menu and when one box is selected its border is red and all the other divs borders are black. The problem I have is, is there an easy way to make it so the neighbouring divs to the selected one don’t have a black border on the side that touches the selected div. This is because then you would have a selected div with red borders have a second border of a black line which I don’t want.

How can you make 2 divs act as if they have a single border?

I am trying to get what I have here perfected.

http://jsfiddle.net/hCK3D/1/

At the moment the white vertical borders interrupt the horizontal grey. This should not be the case, but I do no know how to change that.

  • 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-11T16:21:54+00:00Added an answer on June 11, 2026 at 4:21 pm

    You should use the adjacent selector (+) in CSS to make this happen. Check it out, four items:

    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    

    Here’s your CSS:

    ​.item {
        float:left;
        background: #ccc;
        width: 50px;
        height: 50px;
        border: 1px #000 solid;
        border-right-width: 0;
    }
    
    .item:last-child {
        border-right-width: 1px;
    }
    
    .item:hover {
        border: 1px #f00 solid;
    }
    
    .item:hover + .item {
        border-left-width: 0;
    }
    

    ​.item just sets up each item normally. It makes the right border 0.

    .item:last-child makes it so that the last one has a borer on the right, since it’s the last one and won’t have a div next to it to simulate a border.

    .item:hover makes the hovered item have a red border, and it’s all 4 sizes

    .item:hover +.item grabs the next item in the list and gets rid of its left border since the item just to the left of it now has a red border there.

    You can try it here: http://jsfiddle.net/hCK3D/

    Edit: This one should do the trick! http://jsfiddle.net/hCK3D/7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine a web form with a set of check boxes (any or all of
imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and
Possible Duplicate: Tab behavior using jQuery Imagine that there are many text boxes in
I currently have a HTML select box like below. <select name=item_1> <option value=0>Choose one...</option>
Imagine a view with, say, 4 subviews, next to each other but non overlapping.
imagine a database setup, where x customers can make y orders. normally all customers
Imagine having two list boxes on a form, where the choices in the second
I currently have a page with four list boxes on it and imagine a
Imagine I have 3 rows in a sqlite table. While reading these 3 rows
Imagine the following tables: create table boxes( id int, name text, ...); create table

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.