html - 我的 Css 类不适用于我的 html 文件

标签 html css class coding-style styles

当我想设置它的样式时,“cta”类没有做任何事情。我错过了什么或打错了字吗??任何人都可以帮助我,因为它让我发疯。抱歉,但这个愚蠢的事情告诉我要添加更多信息,有些我现在只是在写一堆垃圾哈哈所以忘记这部分但真的会得到一些帮助

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF=8">
    <meta name="viewport" content="width=device-width, maxium-scale=1.0, minimun-width=1.0,
    initial-width=1.0" />
    <title>Welcome to Drunken Anticz</title>
    <link rel="stylesheet" type="text/css" href="css/screen_style.css" />
    <link rel="stylesheet" type="text/css" href="css/screen_layout_large.css />
    <link rel="stylesheet" type="text/css" media="only screen and (min-width:50px) and 
    (max-width:500px)" href="css/scrren_layout_small.css" />
    <link rel="stylesheet" type="text/css" media="only screen and (min-width:501px) and 
    (max-width:750px)" href="css/scrren_layout_medium.css" />
    <!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif] -->
</head>
    <body>
        <div class="page">

            <header>
                <a class="logo" href="#"></a>
            </header>

            <article>
                <h1>Welcome</h1>
                <p>Welcome to the site blah blah blahblah blah blahblah blah blahblah blah blah
                blah blah blahblah blah blahblah blah blahblah blah blahblah blah blahblah blah blah
                blah blah blahblah blah blah</p>
            </article>

            <div class="promo-container">
                <div class="promo">
                    <div class="content">
                        <h3><a href="#">Events</a></h3>
                        <p>list of eventslist of eventslist of eventslist of eventslist of events
                        list of eventslist of eventslist of eventslist of eventslist of events</p>
                        <p><a class="cta" href="#">More info.</a></p>
                    </div>
                </div>
            </div>
            <div class="promo-container">
                <div class="promo">
                    <div class="content">
                        <h3><a href="#">Loyalty Cards</a></h3>
                        <p>info about loyalty cardsinfo about loyalty cardsinfo about loyalty cards
                        info about loyalty cardsinfo about loyalty cardsinfo about loyalty cards</p>
                        <p><a class="cta" href="#">More info.</a></p>
                    </div>
                </div>
            </div>


        <nav>
            <a href="#">Home</a>
            <a href="#">Event's</a>
            <a href="#">Book Us</a>
            <a href="#">Loyalty Card</a>
            <a href="#">Contact Us</a>
        </nav>

        </div>
    </body>

@charset "UTF=8";

body {
color: #575c7a;
line-height: 1.5em;
font-family: arial;
font-size: 14px;
background: #fff url(../images/background-black-white.jpg) repeat-x 0px 0px;
}

.page {
max-width: 980px;
margin: 0px auto 0px auto;
position: relative;
background-color: #DDDDDF;
}

h1 {
font-size: 2em; font-weight: normal; color: #7A7979; margin: 0 0 .5em 0;
}

h2 {
font-size: 1.7em; margin: 0 0 1em 0;
}

h3 {
font-size: 1.5em; margin: 0 0 1em 0;
}

p {
margin: 0 0 .75em 0;
}

a {
color: #7A7979;
}

a:hover {
color: #009eff;
}

footer {
font-size: .85em; color: #7A7979; background-color: url(../images/background-black-white.jpg; padding: 10px 10px 10px 0px;
}

a.cta {
font-size: 40px;
}

最佳答案

您的问题很容易解决。您在 a.cta 样式之前略去了背景样式中的右括号,这使得解析器在引用背景 url 后采用所有样式。

@charset "UTF-8";

body {
color: #575c7a;
line-height: 1.5em;
font-family: arial;
font-size: 14px;
background: #fff url(../images/background-black-white.jpg) repeat-x 0px 0px;
}

.page {
max-width: 980px;
margin: 0px auto 0px auto;
position: relative;
background-color: #DDDDDF;
}

h1 {
font-size: 2em; font-weight: normal; color: #7A7979; margin: 0 0 .5em 0;
}

h2 {
font-size: 1.7em; margin: 0 0 1em 0;
}

h3 {
font-size: 1.5em; margin: 0 0 1em 0;
}

p {
margin: 0 0 .75em 0;
}

a {
color: #7A7979;
}

a:hover {
color: #009eff;
}

footer {
font-size: .85em; 
color: #7A7979; 
background/*-color -- Color doesn't take a url value*/: url(../images/background-black-white.jpg) 
/* YOU FORGOT THE CLOSING PARENTHESES */; 
padding: 10px 10px 10px 0px;
}

a.cta {
font-size: 40px;
}
<div class="page">
  <header>
    <a class="logo" href="#"></a>
  </header>
  <article>
    <h1>Welcome</h1>
    <p>Welcome to the site blah blah blahblah blah blahblah blah blahblah blah blah blah blah blahblah blah blahblah blah blahblah blah blahblah blah blahblah blah blah blah blah blahblah blah blah</p>
  </article>

  <div class="promo-container">
    <div class="promo">
      <div class="content">
        <h3><a href="#">Events</a></h3>
        <p>list of eventslist of eventslist of eventslist of eventslist of events list of eventslist of eventslist of eventslist of eventslist of events</p>
        <p><a class="cta" href="#">More info.</a>
        </p>
      </div>
    </div>
  </div>
  <div class="promo-container">
    <div class="promo">
      <div class="content">
        <h3><a href="#">Loyalty Cards</a></h3>
        <p>info about loyalty cardsinfo about loyalty cardsinfo about loyalty cards info about loyalty cardsinfo about loyalty cardsinfo about loyalty cards</p>

<!-- begin snippet: js hide: false console: true babel: false -->

关于html - 我的 Css 类不适用于我的 html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38596882/

相关文章:

JavaScript 打断文本框

php - 从列表中选择行

jquery - 尽管有 z-index - Chrome 和 Firefox,文本仍显示在覆盖 div 的顶部

c++ - 使用派生类自动转换

html - 如何居中我的 DIV,它不会去

javascript - 在 jQuery 对象上调用 javascript 函数

html - 如何将 Bootstrap 主体划分为 float 容器

css - 将 Twitter Bootstrap 验证样式和消息应用于 ASP.NET MVC 验证

c++ - 为什么 operator<< 不会将我的自定义类对象隐式转换为字符串

java - Factual API 和 Coldfusion