Hello all,
I have recently submerged myself into another project. I'm trying to place to div elements side by side. I've figured out two ways of doing it and want to know how you would do it. The two ways I did it are:
<div class="div2"></div>
<div class="div3"></div>[/CODE]
Without adding margin-left -4px there would be a gap between the elements (Not sure why).
<div class="div1"></div>
<div class="div2"></div>
</div>
[/CODE]
This code allows me to position the div elements side by side without using the Display property but using the position property.
Those were two ways I came up with to make two elements appear side by side, is there any other way of doing this?
I have recently submerged myself into another project. I'm trying to place to div elements side by side. I've figured out two ways of doing it and want to know how you would do it. The two ways I did it are:
Method 1:
[CODE lang="html" title="HTML Code"]<div class="div1"></div><div class="div2"></div>
<div class="div3"></div>[/CODE]
CSS:
div {
margin-left:-4px;
}
.div1 {
display: inline-block;
width: 100px;
height: 100px;
background-color:red;
}
.div2 {
display: inline-block;
width: 100px;
height: 100px;
background-color:blue;
}
.div3 {
display: inline-block;
width: 100px;
height: 100px;
background-color:green;
}
Method 2:
[CODE lang="html" title="HTML Code"]<div class="mainDiv"><div class="div1"></div>
<div class="div2"></div>
</div>
[/CODE]
CSS:
.div1 {
background-color: red;
height: 100px;
width: 100px;
}
.div2 {
background-color: blue;
height: 100px;
width: 100px;
position: relative;
top:-100px;
left: 100px;
}
Those were two ways I came up with to make two elements appear side by side, is there any other way of doing this?