Overlapping divs with relative position causes empty space

MAP

My "tagline" consists of an orange stripe that extends the full width of the screen, 20px high. On the left is a blue 30% wide strip, same height, and on the right a green 30% wide strip. The left and right strips are supposed to be divs positioned just right to cover up the orange full-width strip, but they are not working right.

It looks OK on Chrome 43 on Windows 7. But it has two problems: it affects the menu below it by causing it to wrap (all browsers), and the left and right taglines are not quite lined up properly when viewed in Firefox 39, Safari on iPad, and Chrome on iPad. I have that feeling that I'm doing something really wrong but I don't know what it is. Any ideas?

Here is the fiddle: http://jsfiddle.net/postiffm/kg1gLyrv/

It is live at aahcdc.com so you can see the problem easily.

#Tagline {
    display: block;
    height: 20px;
    border-style: solid;
    border-radius: 7px;
    border-color: #ff9706;
    background-color: #ff9706;
    color: white;
    font-weight: normal;
    letter-spacing: 2px;
    text-align: center;
    margin-top: 7px;
    margin-bottom: 10px;
}
#TaglineLeft {
    position: relative;
    height: 20px;
    width: 30%;
    bottom: 21px;
    left: -3px;
    border-style: solid;
    border-radius: 7px;
    border-color: #6673aa;
    background-color: #6673aa;
}
#TaglineRight {
    position: relative;
    float: right;
    height: 20px;
    width: 30%;
    bottom: 47px;
    right: -4px;
    border-style: solid;
    border-radius: 7px;
    border-color: #7e922e;
    background-color: #7e922e;
}
<div id="Tagline">My Tag Line.
<div id="TaglineLeft"></div>
<div id="TaglineRight"></div>
</div>

Stickers

The element still takes up space where it originally was when using relative position. I recommend to use absolute position for the two side elements. Simplified demo follows.

#Tagline {
    color: white;
    font-weight: normal;
    letter-spacing: 2px;
    text-align: center;
    margin-top: 7px;
    margin-bottom: 10px;
    padding: 5px;
    border: 0 solid #ff9706;
    border-radius: 7px;
    background-color: #ff9706;
    position: relative;
}
#TaglineLeft, #TaglineRight {
    position: absolute;
    height: 100%;
    width: 30%;
    top: 0;
    border-radius: 7px;
}
#TaglineLeft {
    left: 0;
    border: 0 solid #6673aa;
    background-color: #6673aa;
}
#TaglineRight {
    right: 0;
    border: 0 solid #7e922e;
    background-color: #7e922e;
}
<div id="Tagline">
    My Tag Line.
    <div id="TaglineLeft"></div>
    <div id="TaglineRight"></div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Overlapping divs with relative position causes empty space

From Dev

position relative overlapping position fixed

From Dev

Position relative container white space

From Dev

HTML CSS Div overlapping absolute & relative position

From Dev

Two divs (left, right) in parent, right with fixed width, left fill free space, both in same line. (without position relative/absolute)

From Dev

Inline-block display of divs with position relative

From Dev

HTML How to position a button relative to two divs?

From Dev

Height difference divs with `position: relative;` and smaller font

From Dev

Relative positioning without z-index causes overlapping

From Dev

How to make position:absolute divs follow the paddings of a position:relative parent;

From Dev

How to remove the empty space between divs in CSS?

From Dev

CSS Flex - Filling empty space with divs

From Dev

HTML Flex divs leaving empty space on the right

From Dev

Divs overlapping

From Dev

Position divs with dynamic widths horizontally relative to one another

From Dev

Scale floating divs not relative to their parent without position:absolute

From Dev

How do I remove white space due to position relative of CSS?

From Dev

How to avoid overlapping between two divs positioning absolute inside a div positioning relative?

From Dev

Why is there a few pixels of white space margin at the bottom of position absolute divs

From Dev

How to fill page horizontally with divs without empty space at the end

From Dev

TextViews overlapping in Relative layout

From Dev

I have absolute position inside relative div, when I zoom in on to the device layout is overlapping the parent

From Dev

Why are positioned divs overlapping?

From Dev

Overlapping droppables in scrolling divs

From Dev

Overlapping centered divs with flexbox?

From Dev

Border Overlapping Floated Divs

From Dev

Overlapping divs in a page

From Dev

Randomly positioned divs with no overlapping

From Dev

Overlapping random divs

Related Related

  1. 1

    Overlapping divs with relative position causes empty space

  2. 2

    position relative overlapping position fixed

  3. 3

    Position relative container white space

  4. 4

    HTML CSS Div overlapping absolute & relative position

  5. 5

    Two divs (left, right) in parent, right with fixed width, left fill free space, both in same line. (without position relative/absolute)

  6. 6

    Inline-block display of divs with position relative

  7. 7

    HTML How to position a button relative to two divs?

  8. 8

    Height difference divs with `position: relative;` and smaller font

  9. 9

    Relative positioning without z-index causes overlapping

  10. 10

    How to make position:absolute divs follow the paddings of a position:relative parent;

  11. 11

    How to remove the empty space between divs in CSS?

  12. 12

    CSS Flex - Filling empty space with divs

  13. 13

    HTML Flex divs leaving empty space on the right

  14. 14

    Divs overlapping

  15. 15

    Position divs with dynamic widths horizontally relative to one another

  16. 16

    Scale floating divs not relative to their parent without position:absolute

  17. 17

    How do I remove white space due to position relative of CSS?

  18. 18

    How to avoid overlapping between two divs positioning absolute inside a div positioning relative?

  19. 19

    Why is there a few pixels of white space margin at the bottom of position absolute divs

  20. 20

    How to fill page horizontally with divs without empty space at the end

  21. 21

    TextViews overlapping in Relative layout

  22. 22

    I have absolute position inside relative div, when I zoom in on to the device layout is overlapping the parent

  23. 23

    Why are positioned divs overlapping?

  24. 24

    Overlapping droppables in scrolling divs

  25. 25

    Overlapping centered divs with flexbox?

  26. 26

    Border Overlapping Floated Divs

  27. 27

    Overlapping divs in a page

  28. 28

    Randomly positioned divs with no overlapping

  29. 29

    Overlapping random divs

HotTag

Archive