【问题标题】:Cannot overwrite CSS无法覆盖 CSS
【发布时间】:2012-04-09 03:59:52
【问题描述】:

我想在我的网站中嵌入一些样式,但是没有显示正确的样式,我不知道为什么。

我的代码在这里:

<head>
...
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"/>
<style type="text/css">
#bd { font-family: 'Neuton', serif;  color:#646464; font-size:16px; line-height:21px; font-weight:200;}
...
</head>

<body>
...
<div class="container" id="bd">
    I want to use the font "Neuton' here. But I fail to do it..
</div>
</body>

谁能帮我解决这个问题:(?

*******更新* *

我仍然找不到原因,让我提供更多上下文: 我正在练习使用 HTML/CSS 编写作品集,这是我的所有代码:

<head>
<title> XXXXX </title>  
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"/>
<link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css"/>
<link href="http://fonts.googleapis.com/css?family=Neuton:200" rel="stylesheet" type='text/css'/>
<link href="http://fonts.googleapis.com/css?family=Terminal+Dosis:300" rel="stylesheet" type="text/css"/>
<style type="text/css">
            body { padding-top: 40px;}

            #bd { font-family: 'Neuton', serif;  color:#646464; font-size:16px; line-height:21px; font-weight:200;}

            #bd a { 
                text-decoration:  none;     
                border-bottom: 1px dotted; 
                color:#646464;
            }
            #bd a:hover { text-decoration:  none; border-bottom: 1px dotted; color:#646464; background-color:#c0f4ff; }
            h1 { 
                font-family: 'Terminal Dosis', sans-serif;  
                color:#646464; 
                padding:0px; 
                margin-top:-14px; 
                margin-bottom:0px; 
                font-weight:300; 
                font-size:15px;
            }
            #sections { font-family: 'Terminal Dosis', sans-serif;  color:#7a7a7a; padding:0px; font-weight:300; font-size:80%; line-height:15px;}

            #name    { font-family: 'Oswald', sans-serif;   font-size:20px; color:#7a7a7a; padding-bottom:7px;}

            .dashbar { border-top: 1px dashed #bbbbbb; margin-bottom: 35px; margin-top:00px; }
            #active { background-color:#c0f4ff; color:#646464; width:100%;}
            #navlist li { color:#7a7a7a; font-family: 'Oswald', sans-serif; font-size:15px; display: inline;
                list-style-type: none; float:right; padding-left:74px; padding-top:2px; padding-bottom:0px; }
            a { text-decoration:  none; color:#7a7a7a;  }
            a:hover {color:#646464; text-decoration:  none; background-color:#c0f4ff;  } /*color:: the color displayed when you mouse over the link*/
            a:visited { text-decoration:  none;  ;}/* mouse over link */
            a:active {  background-color:#c0f4ff; color:#646464; } /*the one that is activated */

    </style> 
</head>
<body>
<div class="container">
    <div class="row">
        <div class="span4" id="name">My Name</div>
        <ul id="navlist">
            <li>
                <a href="projects.html">PROJECTS</a>
            </li>
            <li>
                <a id="active" href="index.html">HOME</a>
            </li>
        </ul>
    </div>
    <div class="dashbar"></div>
    <div class="container">
        <div class="row">
            <div class="span-one-third" id="bd">
                <!-- content-->
                <h1>ABOUT</h1>
                ***I want to use the font Neuton Here***
            </div>

            <div class="span10" style="margin-left: 30px;">
                <!-- put an image here -->

            </div>
        </div>
    </div>

</div>    
</body>

【问题讨论】:

  • 关闭那个&lt;style&gt;标签了吗?
  • 可能是一个愚蠢的问题,但你从哪里得到字体?你的电脑上安装了吗?如果没有,您是否使用@font-face?
  • 好的,所以Neuton 字体不显示...您至少得到serif 和其他样式,还是CSS 完全失败?
  • 确实这是一个愚蠢的问题... 1. 我确实关闭了
  • 我发现了一个非常愚蠢的错误,谢谢大家!我在代码中使用了注释符号“//”,因为我认为注释符号应该与C相同(/ * * /),但实际上这里没有单行注释......我多么愚蠢...... .

标签: html css twitter-bootstrap


【解决方案1】:

这可能是因为你错过了&lt;/style&gt; 标签。您的代码没有显示它。

【讨论】:

    【解决方案2】:

    我不知道那个引导程序,但是我认为你应该导入字体,我使用了 google api。 jsFiddle

    【讨论】:

      【解决方案3】:

      在某些时候,如果 css 代码已更改,您应该清除浏览历史记录以使 css 正常工作

      【讨论】:

        【解决方案4】:

        可能有两个问题:

        1. 您是否关闭了&lt;style&gt; 标签? (&lt;/style&gt;)
        2. 你从哪里得到的字体?你的电脑上安装了吗?如果不是,您需要使用@font face

        如果你关闭了&lt;style&gt;标签和/或使用了@font face,你最好将它包含在你的代码中,会有很多人告诉你这样做。

        感谢阅读!

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-04-19
          • 2015-03-15
          • 2012-04-14
          • 1970-01-01
          • 2016-12-18
          • 2016-09-18
          相关资源
          最近更新 更多