容器不包装内容 [英] Container not wrapping the content

查看:125
本文介绍了容器不包装内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在容器中包含内容,但无法做到这一点!
这是我使用的代码。我知道他们可能是错误的。我做错了什么?

I tried to contain the contents with in a container and am not able to do so! this is the code I used. I know their might be errors. What am I doing wrong?

CSS:

.container {
    max-width: none !important;
    width: 960px;
}

.rectangle {
    min-height: 40px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    height: 65px;
    position: fixed;
    top: 0px;
    right: 0px;
    left: 0px;
    border-radius: 0px;
    background-color:#67518e;

}

HTML:

HTML:

<div class="rectangle"> 
  <div class="container">
    <a href="" style="float:left;color:white;">sample1</a>
    <a href="" style="float:right;color:white;">sample2</a>
  </div>
</div>


推荐答案

好吧,现在我得到要存档的内容。

Ok now I get what want to achive.

要包装和水平居中(我假设你想这样做)你需要

To wrap it and center horizontally (I assume you want to do it) you need to

margin: 0 auto;

转换为.container

to .container

注意:因为的位置没有任何水平滚动:固定;

提示:在这种情况下,如果你创建了css的选择器树

TIP: If you create css do tree of selectors in this case

.rectangle{}

然后

and then

.rectangle .container{}

这里是示例 JSFIDDLE

这篇关于容器不包装内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆