CSS solution to keeping <div> fixed when screensize changes
This code has 1. textarea on the left 2. a div on the right Both are next to each other.
The problem: #cxt-machine1 moves/changes or开发者_开发知识库 does not stay positioned when screen size changes, when margin-left:600px;
is changed also.
#cxt{position:relative; margin:auto; width:70%; height:300px; border:#CCCCCC 1px solid; background-color:#EEEEEE; margin-bottom:50px;}
<div id="cxt">
<span>
<div style="position:relative; left:20px; width:50%; height:10px; margin-bottom:10px;">
<span id="B1" class="styling">B1</span>
<span id="I1" class="styling">I1</span>
<span id="U1" class="styling">U1</span>
<span id="I2" class="styling">I2</span>
<span id="I3" class="styling">I3 Link</span>
<span id="B2" class="styling">B2</span>
<span id="S1" class="styling">S1</span>
</div>
<div id="PCxt">
<form method="post" action="">
<textarea cols="75" rows="10" id="Tmat" name="Tmat" style=" position:relative; left:0px"></textarea>
<br>
<input type="submit" value="Submit" id="Submit">
</form>
</div>
</span>
<span>
<div> style="position:relative; width:48%; height:150px; left:448px; top:-258px; max-width:48%; max-height:5px; text-align:center; font-family:arial; font-size:14px; font-weight:bold;">Cxt-machine Preview</div>
<div id="cxt-machine-1" style="position:fixed; width:30%; height:250px; margin-left:600px; top:445px; max-width:30%; max-height:250px; overflow: auto; background-color:#ffffff; border:#CCCCCC solid 1px;"></div>
</span>
</div>
Looking for solution to keep #cxt-machine1
fixed in a position irrespective of window size.
Sorry...converted everything to table, though I wanted to get the coding tableless, but running out of time, thanks for all your help
Give the div, #cxt
a width in pixels, and you should get the result you want.
Also, give the textarea a width based on percentage or pixels, and don't rely on the cols
attribute to get the styling you want.
精彩评论