jquery - 100% Div 居中,固定宽度的内部 Div

标签 jquery html css

我遇到了一个 CSS 问题,需要一些建议。我有一个包含固定宽度的 100% div。在 27"上,一切看起来都很好 - 黄色 div 完美居中。

当我调整窗口大小时,黄色的固定栏仍然可见,但只要您向右滚动,100% 的 div 就不会调整为当前宽度。

<html>
    <head>
        <title></title>
    </head>
    <body>

    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />    

    <style type="text/css">    

    #footer {
      background-color: #333333;
      color: #ffffff;
      margin-top: 35px;
      padding-bottom: 30px;
      padding-top: 15px;
      position: relative;
      bottom: 0px;
      font-size: 90%;
    }    

    #inner {
      background-color: #feb400; 
      width: 960px;
      margin-left: auto;
      margin-right: auto;
    }    

    </style>    

  <body>
    <footer id="footer">
      <div id="inner">lorem ipsum div.</div>
    </footer>
  </body>
</html>

http://jsfiddle.net/nghg4zd5/

我希望始终调整黑色 100%-div 的大小。我怎样才能做到这一点?

谢谢。

最佳答案

试试这个,你应该在 100%div 中使用 min-width 样式属性(就像相同的内部宽度值)

jsfiddle demo

关于jquery - 100% Div 居中,固定宽度的内部 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27058903/

相关文章:

html - CSS: anchor 不接受高度

python - 使用 Python 抓取 HTML 时出现 Errno 10054 : how to reconnect

html - 设置元素的语言属性会导致子元素出现 unicode 字符样式错误

css - 水平对齐元素,jquery mobile

jquery - fancyBox - YouTube 视频不会显示

javascript - jQuery:模板化数据

javascript - 当我点击一张图片时,它会弹出,但我想模糊其余部分

html - 当元素从 display none 中显示时,Div 不会自动调整高度

css - 我的 div 不会排列 -

jQuery 动画 : Make a sprite appear to be walking, 不 float /滑动