0

我正在为我的网站做一个新设计。我想我应该做不同的盒子。他们所有的bordersbackgrounds必须相同,但他们的heightswidths必须不同。所以,我创建了一个 CSS 类。

.box
{
    background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwNWFmZiIgc3RvcC1vcGFjaXR5PSIwLjUiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNWFmZiIgc3RvcC1vcGFjaXR5PSIwLjUiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);
    background: -moz-linear-gradient(left,  rgba(0,90,255,0.5) 0%, rgba(0,90,255,0.5) 100%);
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,90,255,0.5)), color-stop(100%,rgba(0,90,255,0.5)));
    background: -webkit-linear-gradient(left,  rgba(0,90,255,0.5) 0%,rgba(0,90,255,0.5) 100%);
    background: -o-linear-gradient(left,  rgba(0,90,255,0.5) 0%,rgba(0,90,255,0.5) 100%);
    background: -ms-linear-gradient(left,  rgba(0,90,255,0.5) 0%,rgba(0,90,255,0.5) 100%);
    background: linear-gradient(to right,  rgba(0,90,255,0.5) 0%,rgba(0,90,255,0.5) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#80005aff', endColorstr='#80005aff',GradientType=1 );

    border:thick white groove;
    border-bottom-color:gray;
    border-right-color:gray;
    border-top-left-radius:1em;
    border-bottom-right-radius:1em;

}


我将 HTML 代码作为 -

    <body onload="load()">

    <center>

        <div style="width:1120px">
            <img src="images/blu-logo.png" style="float:left;">     
            <div class="box" style="width:900px;height:50px;float:right;margin-top:100px;">
            </div>
        </div>

        <div class="box" style="width:900px;height:500px;">
            <p>Sample text</p>
        </div>          
    </center>

</body>


我不知道如何,但是当我在浏览器中查看文件时发生了一些疯狂的事情<div>,因为应该在另一个之下的除法()实际上与第一个相同。

4

2 回答 2

1

我认为您的问题与您的浮动元素有关。

尝试将 css 属性“overflow:auto”添加到包含两个浮动元素的 DIV 上。

于 2012-10-29T15:39:30.603 回答
0

Clear the floated div/img - you can add an empty div with a style attribute or give it a clear class to use for other elements (br is an option as well)

于 2012-10-29T15:40:23.527 回答