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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:36:04+00:00 2026-05-25T23:36:04+00:00

Two inline-block elements next to each other. .e{border:1px #ccc solid} .e:hover{border-color:#555} What I’d like

  • 0

Two inline-block elements next to each other.

.e{border:1px #ccc solid}
.e:hover{border-color:#555}

What I’d like is to reduce the 1px+1px border between them to a shared 1px border.

To illustrate.

---------
|   |   |
---------

Select first element.

+++++-----
+   +    |
+++++-----

Select second element.

-----+++++
|    +   +
-----+++++

It’s simple to reduce the 2px border to 1px by setting either border-right or border-left to 0, but how to keep the 1px shared border when either element is selected?

Without JavaScript.

  • 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-05-25T23:36:05+00:00Added an answer on May 25, 2026 at 11:36 pm

    You could give them a -1px left margin to get their borders overlapping and then undo that margin on the first one. Then adjust the z-index on hover (and don’t forget position: relative to make the z-index work). Something like this:

    .e {
        border: 1px #ccc solid;
        position: relative;
        margin-left: -1px;
    }
    .e:first-child {
        margin-left: 0;
    }
    .e:hover {
        border-color: #555;
        z-index: 5;
    }
    

    Demo: http://jsfiddle.net/ambiguous/XTzqx/

    You might need to play with the :first-child a bit depending on how your HTML is structured; a couple other options if :first-child or another pseudo-class won’t work:

    • Wrap it all in a <div> with padding-left: 1px to kludge around the margin-left: -1px .
    • Add an extra class to the first one that has margin-left: 0.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to horizontally center two (or possibly more) inline-block elements inside a container
I'm trying to put some (vertically-stacked) display:block elements within a display:inline-block element. According to
I have two divs, inline. One displays a measurement, the other displays a unit
Short version: When two lists are adjacent to each other, is there a way
How do I get two buttons to appear one above the other in a
So I've been struggling on a rather weird problem. I've tried everything from display:inline-block
I expected the two span tags in the following sample to display next to
Well I have two buttons, each image in a span, and one should be
My data structure is a linked list of blocks. A block contains 31 elements
Say I have several inline-block div tags, like this <div class=image> </div> <div class=image>

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.