右浮动和左浮动元素在语义ui中从容器中出来

时间:2017-11-05 18:08:35

标签: html css semantic-ui

正如你在这里可以看到的那样: https://jsfiddle.net/qar4n4ey/6/ 底部的两个按钮部分位于容器外部。它发生在我向左和向右漂浮它们的时候。如何将它们放在容器内?

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>MYMDB</title>
        <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.css">
        <link rel="stylesheet" type="text/css" href="/stylesheets/app.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    </head>
    <body>

<div class="ui main center aligned text container segment">

    <div class="ui huge header">Search for a TV show</div>
    <form class="ui form" action="results" method="GET">
        <div class="ui search">
              <div class="ui icon input">
                <input class="prompt" type="text" placeholder="Tv shows..." name="search">
                <i class="search icon"></i>
              </div>
              <div class="results"></div>
        </div>


        <input id="greenbtn" class="ui green button" type="submit">
    </form>



    <a id="run" href="/run" class="ui left floated blue animated button" tabindex="0">
      <div class="visible content">Run python</div>
      <div class="hidden content">
          <i class="terminal icon"></i>
      </div>
     </a>

    <a id="show-data" href="/data" class='ui right floated disabled button'> See the table </a>

</div>

        </body>
</html>

还有一些css

#greenbtn {
  margin-top:10px;
}

3 个答案:

答案 0 :(得分:5)

所有给出的答案都没有使用语义UI的功能。如果您想以语义UI方式进行,那么您可以使用清除 serment:

validate

答案 1 :(得分:1)

也可以使用float:left作为容器

 .ui.container{
      float: left; // you could also use display: inline-block;
      width: 100% !important;
    }

答案 2 :(得分:1)

在浮动元素后添加clear: both,或在父框中添加overflow: hidden

.main.container {overflow: hidden}

https://jsfiddle.net/qar4n4ey/12/