【问题标题】:css parts are missing when loading from wwwroot从 wwwroot 加载时缺少 css 部分
【发布时间】:2022-02-02 18:22:48
【问题描述】:

我将网站的工作版本发布到我的 wwwroot 文件夹,但是当我打开网站时,一些设计丢失了。 我在 chrome 中查看了 devTools (sources) 并注意到我的 css 的某些部分丢失了,当我从 wwwroot 文件夹手动打开 css 时,我看到这些部分实际上在那里。 什么可能导致选择性 CSS 加载? 我的 css 文件的缺失部分:

#layer {
    background: url(http://s14.directupload.net/images/111129/44ga9qid.png);
    height: 550px;
    background-repeat: repeat;
    position: absolute;
    z-index: 3;
    width: 100%;
    top: 0;
    left: 0;
}

#slide {
    position: relative;
    z-index: 1;
}

.menufixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99999;
    border-bottom: chocolate 8px solid;
    background-color: rgb(0, 0, 0);
    box-shadow: 0 0 10px black;
}

发布到 wwwroot 文件夹的整个 css 文件:

.menu_item {
    color: #FFFFFF;
    border-top: 4px solid #B6B5B5;
    display: inline-block;
    font-family: Arial;
    font-variant: small-caps;
    font-weight: normal;
    padding: 5px 2px 0px 2px;
    text-decoration: none;
    /* font-weight: bold; */
    letter-spacing: 2px;
    margin: 5px;
}

#Top {
    border-bottom: chocolate 8px solid;
    /* margin-bottom: 3%; */
    background-color: rgb(0, 0, 0);
    box-shadow: 0 0 10px black;
}

a {
    text-decoration: none;
    color: #5E5E5E;
}

#Logo {
    color: #5E5E5E;
    font-family: 'Reenie Beanie', cursive;
    display: inline-block;
    margin-right: 3vw;
    background: url(http://www.elinorart.com/Gallery/latest%20artworks/slides/93.jpg) no-repeat, #5E5E5E;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1 {
    font-size: 70px;
    margin: 5% 0;
}


h1:hover {
    color: chocolate;
}

a:hover, a div:hover {
    color: chocolate;
}

#menu_bar {
    display: inline-block;
}

#contact_text {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 10px;
    /* font-weight: 600; */
    font-size: 16px;
    /* font-family: -webkit-pictograph; */
    color: #5E5E5E;
    /* letter-spacing: 0px; */
}

#bottom_left p {
    padding: 0px 49px 0 64px;
}

#bottom_center p {
    padding: 0px 62px 0 30px;
}

#contact_details {
    padding-bottom: 10px;
    color: #5E5E5E;
    font-size: 16px;
}

#pageFooter {
    font-size: 0.8em;
    color: #5E5E5E;
    text-align: center;
    font-family: Arial;
    margin-top: 10%;
}

li {
    line-height: 24px;
    font-family: Arial;
    color: #1C1C1C;
    font-size: 16px;
    list-style-type: none;
}

.exhibit_name {
    color: black;
}

#page {
    text-align: center;
    background-color: rgb(232, 232, 232);
}

.page_content {
    font-family: Arial;
    /*text-align: initial;*/
    /* background-color: rgb(232, 232, 232); */
    /* padding-top: 3%; */
}

p {
    font-size: 16px;
    font-family: Arial;
}

@media screen and (max-width: 768px) {
    body {
        background-color: lightblue;
    }
}

body.about_me {
    background-color: green;
}

.borderClass {
    border-color: chocolate;
}

#contactDiv {
    display: inline-block;
}

td {
    vertical-align: top;
}

.contact_field {
    border-bottom-width: 1px;
    border: 1px solid #5E5E5E;
    border-radius: 4px;
    font-size: 16px;
    font-family: Arial, cursive;
    width: 322px;
    height: 24px;
}

.contact_field_desc {
    font-size: 14px;
    padding: 4px;
    font-family: Arial;
    text-align: left;
}

.send_form {
    border-bottom-width: 1px;
    border: 1px solid #5E5E5E;
    border-radius: 4px;
    padding: 5px 28px;
}

body {
    margin: auto;
}

#Facebook {
    /* width: 100%; */
    /* text-align: center; */
    /* margin-left: 40%; */
    /* margin-top: 3%; */
    display: inline-flex;
    margin-top: 2%;
}

#fb-root {
    /*float: left;*/
    vertical-align: central;
    margin-right: 10px;
}

#fb-root2 {
    /*float: right;*/
    vertical-align: central;
    margin-left: 10px;
}

.fb_iframe_widget {
    /* margin-right: 13px; */
    /* float: left; */
    padding-right: 10%;
}

.exhibitions {
    width: 40%;
    margin: 0 5%;
    float: left;
    /*text-align: left;*/
}

.wrapper {
    display: inline-block;
    width: 45%;
    text-align: left;
}

.exhibitions_wrapper {
    padding-right: 3%;
}

ul {
    padding: 0px;
}

    ul li ul li {
        list-style-type: initial;
        padding-bottom: 10px;
    }

.exhibitions_year {
    /* margin-left: -5%; */
    font-family: 'Reenie Beanie', cursive;
    font-size: 37px;
    /* line-height: 1px; */
    margin: 14px 0;
    color: orange;
    color: chocolate;
    font-weight: 500;
    letter-spacing: 4px;
}

.bottom_sections {
    width: 25%;
    /* height: 100%; */
    vertical-align: top;
    text-align: left;
    display: inline-block;
    /* padding: 2%; */
}

.bottom_content {
    /* padding: 0 10%; */
    text-align: center;
}

.buttom_text {
    font-size: 13px;
    line-height: 25px;
    padding: 0 10%;
    text-align: left;
}

#AboutMe p {
    font-size: 13px;
    line-height: 25px;
}

.contact_info {
    display: inline-block;
    width: 19%;
    vertical-align: top;
    padding-left: 30px;
}

#exhibitions_wrapper {
    width: 70%;
}

#AboutMe .wrapper {
    border-right: 1px solid lightgray;
    padding-right: 30px;
}

h3 {
    padding-top: 3%;
    margin: 12px 0;
    font-variant: small-caps;
    font-size: 37px;
    font-weight: normal;
    color: dimgrey;
    letter-spacing: 10px;
    font-family: Arial;
}

h4 {
    font-size: 24px;
    color: dimgrey;
    font-variant: small-caps;
    font-weight: normal;
}

h5 {
    margin-top: 30px;
    /* padding: 15px; */
    border-bottom: 1px solid black;
    font-size: 24px;
    color: dimgrey;
    font-variant: small-caps;
    font-weight: normal;
    text-align: center;
}

h2 {
    /* padding: 0; */
    margin-top: 12px;
    font-variant: small-caps;
    font-size: 32px;
    font-weight: normal;
    color: dimgrey;
    letter-spacing: 10px;
    font-family: Arial;
}

#AboutMe .contact_field {
    width: 187px;
}

input {
    margin-bottom: 15px;
}

.gallery_homepage {
    height: 550px;
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
}

.gallery_homepage div {
    height: 550px;
}

#layer {
    background: url(http://s14.directupload.net/images/111129/44ga9qid.png);
    height: 550px;
    background-repeat: repeat;
    position: absolute;
    z-index: 3;
    width: 100%;
    top: 0;
    left: 0;
}

#slide {
    position: relative;
    z-index: 1;
}

.menufixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99999;
    border-bottom: chocolate 8px solid;
    background-color: rgb(0, 0, 0);
    box-shadow: 0 0 10px black;
}

谢谢!

【问题讨论】:

  • .css 文件的一部分?还是某些 .css 文件已加载而其他文件未加载?
  • 您的控制台窗口(在浏览器开发工具中)是否出现任何错误?
  • @mezod - 只有一个 css 文件,缺少的部分如上。
  • @DarkAshelin - 我编辑了问题,感谢您的帮助。
  • 你确定上传的文件已经正确发送并被服务器接收了吗?该代码是来自您的 wwwroot 文件夹还是来自您的“我的网站的工作版本”?

标签: html css web


【解决方案1】:

可能有很多原因:

  1. 您的 CSS 规则可能会被内联样式覆盖
  2. 它可能会被同一个 CSS 文件中的其他前面的规则(在后面的行中)覆盖
  3. 您可能使用 '!important' 覆盖了 css(这可以在开发工具中看到)
  4. 您的 CSS 文件中可能存在错误,例如语法错误或缺少“;”在规则之后或在规则的开头或结尾块缺少“{”或“}”
  5. 最后但并非最不重要的一点是,您可能没有在 html 中正确包含(正确的)CSS 文件

希望这会有所帮助。

【讨论】:

  • 好吧,我检查了需要受缺少的 css 样式影响的元素(使用检查元素),并且没有应用样式,也没有覆盖(如果有的话,它们会被划掉在开发工具中)。我只有一个 css 文件,当在 devTools 中查看它的内容时 - 大部分都出现了 - 该文件中只缺少上面发布的 css 部分。
  • 您是否检查了语法错误,例如缺少 { 或 } 或 ; ??
  • 是的,检查了它,一切看起来都很好 - 缺少的部分是上面发布的部分。还尝试将其移动到 css 文件的其他区域,但每次仍然缺少这个确切的部分。
  • 您可以编辑您的帖子并向我们展示整个 css 文件吗?
  • 您是否尝试过将 css 部分放在单独的 .css 文件中?
【解决方案2】:

我刚刚遇到了一个类似的问题:我更新了一个 HTML 和一个 CSS 文件并将其上传到服务器。在浏览器中重新加载时,HTML 文件中的更新显示,但 CSS 中的更新没有。那是因为浏览器(在我的情况下是 Chrome)缓存的方式。在 Inkognito-Tab 中打开或删除缓存时,它确实有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-10
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    • 2021-07-14
    • 1970-01-01
    相关资源
    最近更新 更多