繁体   English   中英

CSS不适用于HTML页面

[英]CSS not applying to HTML page

我最近在记事本中做了一些HTML的测试设计,效果很好。 我决定保留设计,并将网站扩展为多页网站-因此CSS需要进入外部CSS文件。 我这样做后,CSS立刻停止为我的页面工作。

我尝试将CS​​S编码粘贴回HTML文件,但仍然无法正常工作。 我已经花了好几个小时来尝试解决问题,但是仍然无法解决我的问题。

我错过了一个明显的错误吗?

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="Test">
    <meta name="keywords" content="test">
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <title>West</title>
    <style type="text/css">
        html, body {
            height100%;
            margin 0px;
            padding 0px;
        }
        video#bgvid {
            position fixed;
            right 0;
            bottom 0;
            min-width 100%;
            min-height 100%;
            width auto;
            height auto;
            z-index -100;
            background url(imgillamal.png) no-repeat;
            background-size cover;
        }
        #wrapper {
            background-color rgba(255, 255, 255, 0.7);
            -webkit-box-shadow 0px 0px 54px -7px rgba(0, 0, 0, 0.75);
            -moz-box-shadow 0px 0px 54px -7px rgba(0, 0, 0, 0.75);
            box-shadow 0px 0px 54px -7px rgba(0, 0, 0, 0.75);
            width 800px;
            height 100%;
            min-height 100%;
            margin auto;
        }
        #header {
            width 800px;
            height 230px;
            margin auto;
            padding-top 2px;
        }
        .map_image {
            display block;
            width 800px;
            height 230px;
            position relative;
            background-position 0 0;
            background-repeat no-repeat;
        }
        .map_image .map_link {
            display block;
            position absolute;
            text-indent -999em;
            overflow hidden;
        }
        .map_image #map_link_0 {
            width 133px;
            height 131px;
            top 50px;
            left 92px;
        }
        .map_image #map_link_1 {
            width 156px;
            height 112px;
            top 58px;
            left 536px;
        }
        .map_image #map_link_2 {
            width 54px;
            height 46px;
            top 54px;
            left 34px;
        }
        .map_image #map_link_3 {
            width 59px;
            height 51px;
            top 129px;
            left 226px;
        }
        .map_image1 {
            display block;
            width 800.1818182468414px;
            height 50.18181824684143px;
            position relative;
            background-position 0 0;
            background-repeat no-repeat;
        }
        .map_image1 .map_link1 {
            display block;
            position absolute;
            text-indent -999em;
            overflow hidden;
        }
        .map_image1 #map_link_4 {
            width 64.36363649368286px;
            height 39.36363649368286px;
            top 3.90625px;
            left 141.9033966064453px;
        }
        .map_image1 #map_link_5 {
            width 95.36363649368286px;
            height 36.36363649368286px;
            top 7.897705078125px;
            left 416.9033966064453px;
        }
        .map_image1 #map_link_6 {
            width 81.36363649368286px;
            height 37.36363649368286px;
            top 9.90057373046875px;
            left 226.9033966064453px;
        }
        .map_image1 #map_link_7 {
            width 79.36363649368286px;
            height 36.36363649368286px;
            top 6.903411865234375px;
            left 325.90907287597656px;
        }
        .map_image1 #map_link_8 {
            width 111.36363649368286px;
            height 36.36363649368286px;
            top 0.909088134765625px;
            left 524.9005279541016px;
        }
        #content {
        }
        #social {
            bottom0;
            positionfixed;
            z-index150;
            _positionabsolute;
            _topexpression(eval(document.documentElement.scrollTop+ (document.documentElement.clientHeight-this.offsetHeight)));
            width 800px;
            height72px;
            margin-bottom 20px;
            text-align center;
        }
        .outline {
            border 2px solid #80b78f;
            box-shadow 3px 3px 5px rgba(0, 0, 0, 0.6);
            -moz-box-shadow 3px 3px 5px rgba(0, 0, 0, 0.6);
            -webkit-box-shadow 3px 3px 5px rgba(0, 0, 0, 0.6);
        }
        #sociallinks {
            height 8-px;
            margin-top 525px;
            text-align center;
            font-size 20px;
            font-family Cooper Std Black;
            letter-spacing 5px;
        }
        #logolinks2 {
            text-align center;
        }
        #twitterfeed {
        }
    </style>
</head>

您还应该附加身体标签内的内容。 关于CSS,由于您在很多地方都省略了“:”,因此该CSS无效,例如,

border 2px solid #80b78f;
should be
border:2px solid #80b78f;

第一个声明中有错字

html, body {
height100%;
margin 0px;
padding 0px;
... }

它应该是

html, body {
height: 100%;
margin:0px;
padding:0px;
}

许多其他地方也缺少:我建议添加这些冒号并重试。

你应该把:属性和价值之间; 如果看到CSS代码,则永远不要使用此代码。 我已修复它,请复制此文本并将其粘贴到您的html文件中

<style type="text/css">
html, body {
height : 100%;
margin : 0px;
padding : 0px;
}
video#bgvid {
position : fixed; right : 0; bottom : 0;
min-width  : 100%; min-height : 100%;
width : auto; height : auto; z-index : -100;
background : url(imgillamal.png) no-repeat;
background-size : cover;
}
#wrapper {
background-color : rgba(255, 255, 255, 0.7);
-webkit-box-shadow : 0px 0px 54px -7px rgba(0,0,0,0.75);
-moz-box-shadow : 0px 0px 54px -7px rgba(0,0,0,0.75);
box-shadow : 0px 0px 54px -7px rgba(0,0,0,0.75);
width : 800px;
height : 100%;
min-height : 100%;
margin : auto;
}
#header {
width : 800px;
height : 230px;
margin : auto;
padding-top : 2px;
}
.map_image { display : block; width : 800px; height : 230px; position : relative; background-position : 0 0; background-repeat : no-repeat; }
.map_image .map_link { display : block; position : absolute; text-indent : -999em; overflow :     hidden; }
.map_image #map_link_0 { width : 133px; height : 131px; top : 50px; left : 92px; }
.map_image #map_link_1 { width : 156px; height : 112px; top : 58px; left : 536px; }
.map_image #map_link_2 { width : 54px; height : 46px; top : 54px; left : 34px; }
.map_image #map_link_3 { width : 59px; height : 51px; top : 129px; left : 226px; }
.map_image1 { display : block; width : 800.1818182468414px; height : 50.18181824684143px; position : relative; background-position : 0 0; background-repeat : no-repeat; }
.map_image1 .map_link1 { display : block; position : absolute; text-indent : -999em; overflow : hidden; }
.map_image1 #map_link_4 { width 64.36363649368286px; height : 39.36363649368286px; top 3.90625px; left 141.9033966064453px; }
.map_image1 #map_link_5 { width 95.36363649368286px; height : 36.36363649368286px; top : 7.897705078125px; left 416.9033966064453px; }
.map_image1 #map_link_6 { width : 81.36363649368286px; height : 37.36363649368286px; top : 9.90057373046875px; left 226.9033966064453px; }
.map_image1 #map_link_7 { width 79.36363649368286px; height : 36.36363649368286px; top : 6.903411865234375px; left 325.90907287597656px; }
.map_image1 #map_link_8 { width 111.36363649368286px; height 36.36363649368286px; top :0.909088134765625px; left 524.9005279541016px;}
#content {
}
#social {
bottom : 0;
position : fixed;
z-index150;
position: absolute;
width : 800px;
height : 72px;
margin-bottom : 20px;
text-align : center;
}
.outline {
border : 2px solid #80b78f;
box-shadow : 3px 3px 5px rgba(0,0,0,0.6);
-moz-box-shadow : 3px 3px 5px rgba(0,0,0,0.6);
-webkit-box-shadow : 3px 3px 5px rgba(0,0,0,0.6);
}
#sociallinks {
height : 8-px;
margin-top : 525px;
text-align : center;
font-size : 20px;
font-family : Cooper Std Black;
letter-spacing : 5px;
}
#logolinks2 {
text-align : center;
}
#twitterfeed {
}
</style>

最好

有很多错别字。 确保放入冒号和分号:

height: x;

不:

heightx;

您的代码中有很多错别字,主要是CSS中缺少冒号。 这是正确的CSS代码:

html, body {
  height: 100%;
  margin: 0px;
  padding: 0px;
}
video#bgvid {
  position: fixed;
  right: 0;
  bottom: 0;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -100;
  background: url(imgillamal.png) no-repeat;
  background-size: cover;
}
#wrapper {
  background-color: rgba(255, 255, 255, 0.7);
  -webkit-box-shadow: 0px 0px 54px -7px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 0px 54px -7px rgba(0,0,0,0.75);
  box-shadow: 0px 0px 54px -7px rgba(0,0,0,0.75);
  width: 800px;
  height: 100%;
  min-height: 100%;
  margin: auto;
}
#header {
  width: 800px;
  height: 230px;
  margin: auto;
  padding-top: 2px;
}
.map_image { display: block; width: 800px; height: 230px; position: relative; background-position: 0 0; background-repeat: no-repeat; }
.map_image .map_link { display: block; position: absolute; text-indent: -999em; overflow:             hidden; }
.map_image #map_link_0 { width: 133px; height: 131px; top: 50px; left: 92px; }
.map_image #map_link_1 { width: 156px; height: 112px; top: 58px; left: 536px; }
.map_image #map_link_2 { width: 54px; height: 46px; top: 54px; left: 34px; }
.map_image #map_link_3 { width: 59px; height: 51px; top: 129px; left: 226px; }
.map_image1 { display: block; width: 800.1818182468414px; height: 50.18181824684143px; position: relative; background-position: 0 0; background-repeat: no-repeat; }
.map_image1 .map_link1 { display: block; position: absolute; text-indent: -999em; overflow: hidden; }
.map_image1 #map_link_4 { width 64.36363649368286px; height: 39.36363649368286px; top 3.90625px; left 141.9033966064453px; }
.map_image1 #map_link_5 { width 95.36363649368286px; height: 36.36363649368286px; top: 7.897705078125px; left 416.9033966064453px; }
.map_image1 #map_link_6 { width: 81.36363649368286px; height: 37.36363649368286px; top: 9.90057373046875px; left 226.9033966064453px; }
.map_image1 #map_link_7 { width 79.36363649368286px; height: 36.36363649368286px; top: 6.903411865234375px; left 325.90907287597656px; }
.map_image1 #map_link_8 { width 111.36363649368286px; height 36.36363649368286px; top :0.909088134765625px; left 524.9005279541016px;}
#social {
  bottom: 0;
  position: fixed;
  z-index: 150;
  position: absolute;
  width: 800px;
  height: 72px;
  margin-bottom: 20px;
  text-align: center;
}
.outline {
  border: 2px solid #80b78f;
          box-shadow: 3px 3px 5px rgba(0,0,0,0.6);
     -moz-box-shadow: 3px 3px 5px rgba(0,0,0,0.6);
  -webkit-box-shadow: 3px 3px 5px rgba(0,0,0,0.6);
}
#sociallinks {
  height: 8-px;
  margin-top: 525px;
  text-align: center;
  font-size: 20px;
  font-family: "Cooper Std Black";
  letter-spacing: 5px;
}
#logolinks2 { text-align: center; }

您无需将所有内容都放在<style>标记中-具有有效CSS的.css文件可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM