P元素不位于div元素旁边的问题

时间:2017-05-23 16:56:48

标签: html css

正如您在结果中看到的那样,P和H2元素不会与最后一个div对齐 当我添加"浮动"到CSS。可能是因为它将它从正常的文档流中取出并想知道该怎么做。我是CSS和HTML的新手,所以对你的答案的解释会有所帮助。



body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  margin: 0;
  padding: 0;
}
p, h1 {
  margin: 0;
  padding: 0;
}
header {
  background-color: #191919;
  position: fixed;
  width: 100%;
  color: #edf9ff;
  min-height: 70px;
  border-bottom: #0fe216 3px solid;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  margin-top:0;
}

header a {
  text-decoration: none;
  text-transform: uppercase;
  color: #edf9ff;
}

header ul {
  margin: 0;
}

header li {
  list-style-type: none;
  float: left;
  padding-right: 20px;
}
#showtime {
  padding-top:60px;
  padding-bottom:20px;
}
#showtime img {
  width:300px;
  height:300px;
}
/*Image Repz*/

.showright img {
  float:right;
  clear:both;
}

.showright > p, .showright > h2 {
  text-align: center;
}
.showleft {
  float:left;
  clear:both;
}

footer {
margin-top:30px;
  background-color:#191919;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  clear:both;
}
footer p{
  text-align: center;
  color: white;
}

<!DOCTYPE html>
<html>
    <head>
        <title>Photography | Home </title>
        <link href="About.css" rel="stylesheet"/>
        <script type="application/javascript" src="Home.js"></script>
    </head>
    <body>

        <header>
            <div id="branding">
                <h2>PHOTOGRAPHY</h2>
            </div>
            <nav id="links">
            <ul>
                <li><a href="Home.html">Home</a></li>
                <li><a href="About.html">About</a></li>
                <li><a href="#">PHOTO GALLERY</a></li>
                <li><a href="#">VIDEO GALLERY</a></li>
            </ul>
                </nav>
        </header>
        <section id="showtime">
                <div class="showright">
                    <a href="./images/Person1.jpg"><img src="./images/Person1.jpg" width="300px;" height="300px;" ></a>
                    <h2>Image</h2>
                    <p>The image will always try to be unique from the odthers and we will always try to deliver the best photo in our limited time</p>
                </div>
                          <div class="showright">
                    <a href="./images/Person1.jpg"><img src="./images/Person1.jpg" width="300px;" height="300px;" ></a>
                    <h2>Image</h2>
                    <p>The image will always try to be unique from the odthers and we will always try to deliver the best photo in our limited time</p>
                </div>
        </section>
              
        <footer>
            <p>Note that any copyright &copy; is reserved</p>
        </footer>
    </body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案