【问题标题】:Html, Css Background Not ShowingHtml,Css背景不显示
【发布时间】:2018-10-20 11:01:01
【问题描述】:

这可能是一个非常愚蠢的问题,但我的导航 div 的背景不会显示,我真的不知道这个问题,css 文件已链接并使用一些元素。

图像属性 大小:10kb -位深度:32 -尺寸:宽:300 高:190 -文件类型:png -名称:Nav_Background

需要做什么 http://prntscr.com/l89oq0

Index.html

<!DOCTYPE html>
<html>
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width,initial-scale=1">

   <title>Portfolio Template</title>

   <meta name="author" content="name">
   <meta name="description" content="description here">
   <meta name="keywords" content="keywords,here">
   <link rel="shortcut icon" href="favicon.ico" type="">
   <link rel="stylesheet" href="main.css" type="text/css">
 </head>
 <body>

   <div class="nav">

   </div>

   </div>
  </body>
</html>

ma​​in.css

                /*----------Global----------*/
            * {
                margin: 0;
                padding: 0;
                border: 0;
                outline: 0;
                font-size: 100%;
                vertical-align: baseline;
                background: transparent;
            }

            .clearfix::after{
            content: "";
            clear: both;
            display: table;
            }
            html{
                font-family: circular std, sans-serif;
                font-weight: 100;
            }
            body{
                width: 100%;
                margin: auto;
                background: white; /*Replace with background image
                background-position: top;
                background-size: cover;
                background-repeat: no-repeat;*/
            }

            /*----------Navigation----------*/
            .nav {
                background-image: url(images/Nav_Background.png);
                background-position: right top;
                background-size: 300px 191px;
                margin-top: 5px;
            }

【问题讨论】:

    标签: html image css styles


    【解决方案1】:

    &lt;div class="nav"&gt;(如果你正在使用一个名为nav 的类,你真的应该问自己是否应该使用&lt;nav&gt; 元素)没有内容或任何其他可以给它一个高度的东西。

    没有高度,就没有像素可以绘制背景。

    【讨论】:

    • 非常感谢它现在可以工作了,顺便说一句,我继续使用 div。 xD
    猜你喜欢
    • 1970-01-01
    • 2013-04-03
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    • 2020-12-31
    • 2012-04-02
    • 2012-12-11
    • 2013-07-24
    相关资源
    最近更新 更多