简体   繁体   English

如何使用javascript或CSS将div的宽度设置为百分比减去某些像素

[英]how to set width of a div in percentage minus certain pixels using javascript or css

following code represents two divs on my webpage. 以下代码代表了我网页上的两个div。

<div class="left">Left</div>
<div class="right" id="toset">
   <div class="right-top">right-top</div>
   <div class="right-bottom">right-bottom</div>
</div>

i have two divs, left is of fixed width and position, the right one has to be of the remaining width and of absolute position . 我有两个div,左边的宽度和位置固定,右边的宽度和位置绝对固定。

i cannot figure out how to set the width of right one to fill the remaining screen. 我不知道如何设置右一个的宽度来填充剩余的屏幕。

check following link for the full code. 检查以下链接以获取完整代码。

http://jsfiddle.net/X5Bd6/ http://jsfiddle.net/X5Bd6/

If I've understood your question correctly, 如果我正确理解了您的问题,

.right{
        :
    right: 0px;
}

should do the trick. 应该可以。

A live demo at jsFiddle . jsFiddle上的现场演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果在css中设置百分比,我如何检索div的顶部值(以像素为单位)? - How do i retrieve a div`s top value in pixels if it is set in percentage in css? 如何知道是否使用jQuery在百分比或像素中设置了DIV宽度 - How to know if a DIV width is set in Percentage or Pixel using jQuery 使用Javascript或JQuery将div宽度设置为窗口的一半,减去25px - Set div width that is equal half of window with minus 25px using Javascript or JQuery 如何使div 100%宽度减去一定数量? - How to make a div 100% width minus a certain amount? 如果使用 JavaScript 的百分比值,如何获得 CSS 的高度和宽度? - How to get CSS height and width if they are in percentage value using JavaScript? Javascript:计算DIV减去像素的高度 - Javascript: Calculate height of DIV minus pixels 如何在JavaScript中按%(百分比)设置屏幕高度和宽度 - How to set the screen height and width by %(percentage) in javascript 如何设置输入字段以使用TD中可用宽度的100%,减去X像素数? - How to set an input field to use 100% of available width in a TD, minus X number of pixels? 确定DIV的高度以百分比设置,而不是像素 - Determing Height of DIV set in percentage, not pixels 如何在 Javascript 中以百分比或像素自动滚动? - How to autoscroll with percentage or pixels in Javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM