我的代码过于复杂多少(HTML& CSS)

时间:2017-10-16 09:21:26

标签: html css

我想要实现的是2个单独的块引用,每个都有不同的属性,如背景,高度和宽度(我知道我不需要使用样式标记,相反,我应该链接,我知道,不要提它)

<div class="banana">
              <blockquote>
              <style>
        .banana blockquote{background: yellow; height: 50px; width: 100px;}
              </style>
              please work
   <p>I have created a weapon which will destroy all life in Azeroth. `</p>`

              <p> With such genieuss, he battled the enemy for control. </p>
              <p> But he lost. Rip </p>
              </blockquote>
              </div>

              <div class="monkey">
              <blockquote>
              <style>
              .monkey blockquote{ background: red; height: 5px; width: 5px; }
              </style>
              <p> This better work </p>
              </blockquote>
              </div>

1 个答案:

答案 0 :(得分:0)

您不需要使用<div>标记,因为您只是定义了一个类。将类添加到<blockquote>本身以稍微清理一下。

.banana {
  width: 200px;
  height: 200px;
  background: yellow;
}
.monkey {
  width: 250px;
  height: 100px;
  background: red;
}
<!-- Banana Blockquote -->
<blockquote class="banana">
  please work
  <p>I have created a weapon which will destroy all life in Azeroth.</p>
  <p>With such genieuss, he battled the enemy for control.</p>
  <p>But he lost. Rip</p>
</blockquote>

<!-- Monkey Blockquote -->
<blockquote class="monkey">
  <p>This better work</p>
</blockquote>