html - Div不 float

标签 html css

我正在尝试安排网站的页脚。

问题似乎出在 float 语句上。 .logo 应该左对齐,但它是右对齐的。

这是 html:

<!doctype html>
<html lang='es'>
<head>
   <meta charset='utf-8'>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0" />
    <title>Dulkre</title>

    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <!-- HTML Snippet -->

    <!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>
    <div id="page">
        <header>
            <img src="./img/logo.png" id="logo" />

            <nav>
                <ul>
                    <li class="current">
                        <a href="#">Home</a>
                    </li>
                    <li>
                        <a href="#">Quienes Somos</a>
                    </li>
                    <li>
                        <a href="#">Productos</a>
                        <ul>
                            <li>
                                <a href="">Endulzantes</a>
                            </li>
                            <li>
                                <a href="">Life con sucralosa</a>
                            </li>
                            <li>
                                <a href="">Cl&aacute;sico</a>
                            </li>
                            <li>
                                <a href="">Fructofibra</a>
                            </li>
                            <li>
                                <a href="">Mate</a>
                            </li>
                            <li>
                                <a href="">Gourmet</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#">Recetas</a>
                    </li>
                    <li>
                        <a href="#">Bienestar</a>
                    </li>
                    <li>
                        <a href="#">Contacto</a>
                    </li>
                </ul>
            </nav>
        </header>

        <section id="wrapper">
            <article id="slider"></article>

            <article id="cuerpo"></article>
        </section>
    </div>

    <footer>
        <div id="pie">
            <div class="logo">
                <img src="./img/logo.png" />
            </div>

            <div class="copy"></div>
        </div>
    </footer>
</body>
</html>

这是CSS

footer{ height: 115px; width:100%; background: #aad361; }
footer #pie { width:960px; margin:0 auto; height:115px; }
footer #pie .logo { width:168px; float:left; display: block; }

footer #pie .copy { margin-left: 198px; height:115px; display: block; width:762px; }

知道我做错了什么吗?


这是一个你可以看到所有代码的url

http://dulkre.com.ar/newsite/

最佳答案

当您应该 float img 时,您正在 float div 元素。

这是正确的代码:

HTML:

<footer>
    <div id="pie">
      <img class="logo" class="img" src="./img/logo.png" />
    </div>
</footer>

还有 CSS:

footer { 
    height: 115px;
    width:100%; 
    background: #aad361; 
}

footer #pie {
    width:960px;
    margin:0 auto;
    height:115px; 
}

footer #pie .logo { 
    width:168px; 
    float: left; 
}

如果您想使用您的代码并获得相同的结果,只需使用:

.footer #pie .logo img {
     width:168px; 
     float: left; 
}

关于html - Div不 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27894064/

相关文章:

html - 内联 block 元素换行时的CSS,父包装器不适合新宽度

javascript - 有没有办法在 HTML 文件中禁用 javascript?

javascript - 我如何控制要使用 javascript 打印的页数?

html - 为什么列表从包含元素的外部开始?

html - css 中的边距不起作用

html - 响应式设计无法使用 chrome 开发工具,但浏览器可以

jquery - 基于 slider 内容的 DIV 高度在下一张幻灯片上折叠

css - Sharepoint 2013 CSS 旋转不工作

html - Div 不会一直沿着屏幕向下移动

iphone - 将 CSS 和 HTML 与 MFMailComposeViewController 结合使用