【问题标题】:How to make div container float to side of screen regardless of screen resolution?无论屏幕分辨率如何,如何使 div 容器浮动到屏幕的一侧?
【发布时间】:2013-12-08 22:11:52
【问题描述】:

我有一台笔记本电脑和一台台式电脑,台式机是我主要工作的机器。我台式机的显示器尺寸是 1920x1080,笔记本电脑的屏幕是 1366x768。有一天我注意到我一直在做的项目的容器 div 没有出现在我笔记本电脑的屏幕上。无论屏幕的分辨率/大小如何,我都需要容器 div 始终保持在屏幕的右侧。

CSS:

#container {
    margin:0px auto 0 auto;
    height:800px; 
    width:960px; 
    text-align:left; 
    padding-right:0px; 
    float:right; 
    position:relative;
}

【问题讨论】:

    标签: css html alignment css-position containers


    【解决方案1】:

    您可以在 margin 属性中将第二个 auto 替换为 0。

    #container {
      margin: 0 0 0 auto;
      ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-06
      • 1970-01-01
      • 1970-01-01
      • 2020-07-04
      • 1970-01-01
      • 2016-06-28
      • 2015-04-06
      • 1970-01-01
      相关资源
      最近更新 更多