Reputation: 157
I have a small problem with these <span>
elements in a <div>
.
http://jsfiddle.net/kkzLW/179/
Here is the section of CSS code that I'm working with:
.rightRapper {
border-style: dotted;
margin-left: 105px;
margin-top: 0px;
height: 90px;
width: 100px;
display: block;
}
.leftRapper {
border-style: dotted;
margin-left: 0px;
height: 90px;
width: 100px;
display: block;
}
Here is the HTML section:
<div id="battleBox">
<span class="leftRapper">
<span id="buttonColumn">
<span id="container3" class="topButton">
<a href="" id="linktomouseover">+</a>
</span>
<span id="container4" class="bottomButton">
<a href="" id="linktomouseover2">-</a>
</span>
</span>
</span>
<span class="rightRapper">
<span id="buttonColumn">
<span id="container" class="topButton">
<a href="" id="linktomouseover3">+</a>
</span>
<span id="container2" class="bottomButton">
<a href="" id="linktomouseover4">-</a>
</span>
</span>
</span>
</div>
I'm trying to get the <span>
.leftRapper
and .rightRapper
to be side by side in the <div>
battleBox
. However, when I set the CSS display
property to inline
, the <span>s
get squished into a smaller shape for some reason. When I set the display
to block
, it turns them into the size I want but it doesn't display them the way I want, because they're not displayed inline.
What is causing the <span>s
to have a smaller size?
Upvotes: 15
Views: 58568
Reputation: 44581
Add or replace the properties below in the following CSS classes/selectors:
#battleBox {
width: 216px; /* increasing width from 210 to 216 because your border takes 6 extra px*/
}
.rightRapper {
margin: 0px; /* remove all margins to fit two divs in the container */
display: inline-block; /* display block elements in one line */
}
.leftRapper {
margin: 0px;
display: inline-block;
}
Upvotes: 22
Reputation: 275
You could/should add a float: left
to .leftRapper
.
Other options are e.g. adding a negative right margin to .leftRapper
.
Upvotes: 2