调整浏览器窗口大小时,引导程序列重叠

时间:2019-01-03 17:46:07

标签: css twitter-bootstrap

我是Bootstrap的新手,并且正在从事的项目存在一些样式问题。调整窗口大小并缩小窗口后,列开始重叠。我该如何解决这个问题,并使它(在这种情况下为消息)始终与列的左侧对齐?

我在这里做什么错了?

我在这里做了一个示例页面: QueryBase.cs

https://www.bootply.com/JxB5m6qw8Z

enter image description here

<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="/">Chat</a>    
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav"></ul>
      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">User2 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="/users/edit">Settings</a></li>
            <li role="separator" class="divider"></li>
            <li><a rel="nofollow" data-method="delete" href="/users/sign_out">Logout</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>


<div class="fluid-container" style="margin-top: 70px">
<div class="row">

  <div class="col-sm-2 sidebar-main">
    <div class="sidebar-items"> 
      <div class="sidebar-channels">
        <h4>Channels</h4>
        <ul>
          <div class="sidebar-listitem">
            <li># <a data-behavior="chatroom-link" data-chatroom-id="25" href="/chatrooms/25">General</a></li>
          </div>
        </ul>  
      </div>
      <div class="sidebar-users">
        <h4>Current Users</h4>
        <ul>
          <div class="sidebar-listitem">
            <li><a data-behavior="chatroom-link" data-chatroom-id="28" href="/direct_messages/6">User1</a></li>
          </div>
          <div class="sidebar-listitem">
            <li><a data-behavior="chatroom-link" href="/direct_messages/7">User3</a></li>
          </div>
        </ul>  
      </div>
    </div>
  </div>

  <div class="col-sm-10 col-sm-offset-2 body-main"> 
    <div class="room-name">
      <h2>General</h2>
    </div>
    <div class="message-window">    
      <div data-behavior='messages' data-chatroom-id='25' class="messages">
        <div><strong>User2: </strong> sd</div>
        <div><strong>User2: </strong> csd</div>
        <div><strong>User2: </strong> c</div>
        <div><strong>User2: </strong> sdc</div>
        <div><strong>User2: </strong> sd</div>
        <div><strong>User2: </strong> cs</div>
      </div>
      <div class="message-form">
        <form class="new_message" id="new_message" action="/chatrooms/25/messages" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="4NCGg4CJSb0jWbL+Xsx+FuNYTIUM/LD/el5IIuF3cRTHLXy9LzFAIUR+T5C8ATiJKeYdrbceMAeTc79E7OgLGg==" />
          <textarea rows="1" class="form-control" autofocus="autofocus" name="message[body]" id="message_body">
          </textarea>
        </form>
      </div>
    </div> 
  </div>
</div>
</div>

1 个答案:

答案 0 :(得分:1)

我非常确定您的问题是使用col-sm无法正常工作,因为您的屏幕小于该列的大小。尝试改用col-xs

更不用说,您一次使用fluid-container而不是container-fluid