It is a basic HTML question.
I have some div tags, which have some controls and occupy left half of my screem.
I Want to have a div tag to display some messages in the right side? I used somthings like:
float = right;
in my css class. It didn't seem to work. What other properties I need to set.
Here is the code sample
<div class ="header_label">
@Html.GetLocalizedString("program_snapshotRecipientAdress") @Html.TextBox("txtRcpntAdress")
</div>
<div class ="header_label">
@Html.GetLocalizedString("program_snapshotUsertype1") @Html.RadioButton("Usertype", "One", new { id="rb1"})
@Html.GetLocalizedString("program_snapshotUsertype2") @Html.RadioButton("Usertype", "Two", new { id = "rb2" })
<div class ="commentsHeight"></div>
</div>
<div class ="header_label">
@Html.GetLocalizedString("program_snapshotDate") @Html.TextBox("SnapshotDate")
</div>
<div id ="CMSContent">
<div class ="CMS-message">
@Html.Raw("S=This is the div I need to place in the right hand side")
</div>
</div>
Using float and marginThe left div is styled with width:50% and float:left – this creates the green colored div that horizontally covers half of the screen. The right div is then set to margin-left:50% – this immediately places it to the right of the left div.
Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.
With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.
If position: absolute; or position: fixed; - the right property sets the right edge of an element to a unit to the right of the right edge of its nearest positioned ancestor. If position: relative; - the right property sets the right edge of an element to a unit to the left/right of its normal position.
I didn't understand your question so much, but I'll try to answer. If you have some div on the left and you want another one on the right you have two choice:
1) The first one is to set one div on the right and another on the left:
<div>
<div style="float: left; width: 50%">I'm on the left</div>
<div style="float: right; width: 50%">I'm on the right</div>
</div>
2) The second one is to set every div on the left
<div>
<div style="float: left; width: 50%">I'm on the left</div>
<div style="float: left; width: 50%">I'm on the second on the left</div>
</div>
the correct way to your command is
float : right;
If you want your div to be half of your screen you should write something like:
width : 50%;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With