html - 编码新手,需要帮助修复 html/css 线框

标签 html css

我是编码新手,这是我参加 Fullstack 类(class)的第一周,我们有一些我已经准备了一段时间的家庭作业。我设法让我的线框看起来与家庭作业示例相似(我们应该让它看起来一样),但我不确定这段 html/css 代码哪里出了问题。

此外,除了发布我的大部分 CSS 之外,我不确定还有什么其他方式可以展示我正在做的事情,所以如果我做错了,我深表歉意。

:)

我在内容周围放置了红色边框,我试图在所有边上均匀对齐。我已经尝试更改填充、边距、 float 位置、宽度(我所知道的所有这些都会调整框,但我似乎仍然无法让“旁白”内容与其余线框对象对齐。

`````HTML````

        <header class="main-head">
            <p>header</p>
        </header>
        <link rel="stylesheet" href="style.css">
        <nav>nav</nav>
        <div class="divCont">
                <div class="aside1">
                        <aside>aside</aside>
                </div>
                    <div>
                        <div>
                            <article class="sect1">section
                                <p class="art1">article</p>
                                <div class="inside1">
                                        <h3>h1, h2, h3</h3>
                                </div>
                                <div class="paraCont">
                                        <p class="para1">p</p>
                                </div>
                            </article>
                    </div>
                </div>
            </div>
        <footer>footer</footer>
 ```   </div>

`````````外部CSS``````````````````

body {
    margin: auto;
    width: 50%;
    background-color: #777;
    text-align: center;
}

div.layout {
    width: 495px;
}

/* left section */
.sect1 {
    padding: 2%;
    width: 100%;
}

/* right section */
div.aside1 {
    margin-left: 100px;
    border: solid red;
    padding: 2%;
    color: #777;
    width: 200px;
    height: 165px;
    float: right;
    font-size: 18px;}

article {
    color:#777;
    font-size: 18px;
    background-color: #ebebeb;
}

div.divCont {
    border: solid red;
}

/* article box */
.art1 {
    width: 60%;
    color: #ebebeb;
    background-color: #777;
}

/* h1,h2,h3 box */
.inside1 {
    width: 60%;
    color: #ebebeb;
    background-color: #777;
}

/* para box */
p.para1 {
    width: 60%;
    color:#ebebeb;
    background-color: #777;
}

body {
  margin: auto;
  width: 50%;
  background-color: #777;
  text-align: center;
}

div.layout {
  width: 495px;
}


/* left section */

.sect1 {
  padding: 2%;
  width: 100%;
}


/* right section */

div.aside1 {
  margin-left: 100px;
  border: solid red;
  padding: 2%;
  color: #777;
  width: 200px;
  height: 165px;
  float: right;
  font-size: 18px;
}

article {
  color: #777;
  font-size: 18px;
  background-color: #ebebeb;
}

div.divCont {
  border: solid red;
}


/* article box */

.art1 {
  width: 60%;
  color: #ebebeb;
  background-color: #777;
}


/* h1,h2,h3 box */

.inside1 {
  width: 60%;
  color: #ebebeb;
  background-color: #777;
}


/* para box */

p.para1 {
  width: 60%;
  color: #ebebeb;
  background-color: #777;
}
<div class="layout">
  <header class="main-head">
    <p>header</p>
  </header>
  <link rel="stylesheet" href="style.css">
  <nav>nav</nav>
  <div class="divCont">
    <div class="aside1">
      <aside>aside</aside>
    </div>
    <div>
      <div>
        <article class="sect1">section
          <p class="art1">article</p>
          <div class="inside1">
            <h3>h1, h2, h3</h3>
          </div>
          <div class="paraCont">
            <p class="para1">p</p>
          </div>
        </article>
      </div>
    </div>
  </div>
  <footer>footer</footer>
</div>

这就是我想要做的 - https://gyazo.com/6f27f40e4f3e75831b5e4728387ea11f

这是我到目前为止所做的 - https://gyazo.com/79299a16a0eb2208db98519005b3bf9d

最佳答案

这只是一个快速编辑。此外,您的链接标签应位于标签上方


<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
body {
    margin: auto;
    width: 50%;
    background-color: #777;
    text-align: center;
}
div {
    border: 1px solid #000000;
}

.aside1 {
width: 49%;
float: left;
height: 165px;

}
.aside2 {
width: 49%;
float: right;
height: 165px;

}

article {
    background-color:green;
      padding: 20px;
      margin: 5px
}

footer {
width: 100%;

}

</style>
</head>
<body>
 <header class="main-head">
        <p>header</p>
 </header>
 <nav>nav</nav>
        <section class="divCont">
                <div class="aside1">
                        <p>Section</p>
                        <article>
                        Article
                        <div style="background-color:white; margin: 5px;">
                        H1,h2,H3
                        </div>
                        <div style="background-color:yellow;margin: 5px; ">
                        p
                        </div>
                        </article>
                 </div>
                 <div class="aside2">
                 Aside
                 </div>

          </section>



 <footer> Footer </footer>
</body>
</html>

关于html - 编码新手,需要帮助修复 html/css 线框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55861385/

相关文章:

jQuery UI - 添加第二个按钮类型

css - Safari 怪癖模式 : Table takes up entire width of parent.。为什么?

css - 减少子菜单的字体 [wordpress]

css - 双 div "container body-content"标签在 Bootstrap 3.0 中没有正确对齐

javascript - HTML5 Canvas 上的随机多边形形状

jquery - Bootstrap 3 导航栏在打开和消失时闪烁

html - 我的网站没有响应的问题

javascript - 水平滚动的多个粘性部分

image - 允许背景图像表现得像 <img>

html - 各种网站分析方法的优缺点是什么?