简体   繁体   English

HTML如何在页面右侧放置固定宽度的div

[英]HTML How to place a div with a fixed width to the right side of page

I use a javascript library that places itself on the entire web-browser, the script seems to override the mousewheel events so it disables scrolling. 我使用了一个将自己放置在整个网络浏览器上的JavaScript库,该脚本似乎覆盖了mousewheel事件,因此它禁用了滚动。 To solve the scrolling issue i added a div on top of it with a layer, if u place the mouse on the div scrolling is possible again. 为了解决滚动问题,如果您将鼠标放在div上,则可以再次滚动,因此我在其顶部添加了一层div。

Code: 码:

<div style="position:fixed; top:0; left:0; z-index:3;"><div style="height:10000px; width:180px; background-color:#ccc;"></div></div>

Now i wonder how i place a similar div with a layer at the right side of the browser, it should be placed to the right side of screen no matter browser size. 现在我想知道如何在浏览器的右侧放置一个类似的div层,无论浏览器大小如何,都应将其放置在屏幕的右侧。

How to do this with a layer? 如何用一层做到这一点?

Just add some CSS telling it to be at the right side of the screen ( left isn't the only option for position): 只需添加一些CSS告诉它在屏幕的右侧( left不是唯一的位置选项):

#my-div-on-the-right {
  position: fixed;
  right: 0;
  /* whatever other styles (width, height, top, bottom, etc.) */
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM