简体   繁体   English

如何使说明文字在图片下方位于h1下方

[英]How to make the description text line up beside the image, below the h1

I'm trying to make the description text at the bottom line up beside the image. 我正在尝试使描述文本在图像旁边的底行。 I've tried floats, changing the display property to inline, all to no avail. 我尝试了浮动,将display属性更改为inline,但都无济于事。

IMPORTANT: It looks right in the fiddle , but NOT on the web . 重要提示:它看起来很酷 ,但是在网络上却没有 What could be the problem? 可能是什么问题呢?

Here's the HTML: 这是HTML:

<div class="event-wrapper">
   <div class="event">
   <p class="event-date">SEP 15</p>
   <img class="event-image" src="images/backgrounds/graphicstock/AS6_3297_2-103.jpg">
   <h1>Day at Winnekeag</h1>
   <p class="event-text">This is some text about this event. It will be at Camp Winnekeag. We hope you can join us. </p>
   </div>
</div>

And the CSS: 和CSS:

.event-wrapper {
    width: 75%;
    margin: 2rem 15%;
}
.event {
    display: inline-block;
    margin: 1rem 0;
}
.event-date {
    width: 100%;
    display: inline-block;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    background-color: brown;
    color: white;
    margin: 0;
    padding:.5rem;
}
.event-image {
  display:inline;
    width: 40%;
    height: auto;
    float: left;
    margin: 0;
    margin-right: 1rem;
    padding: 0;
    overflow: hidden;
}
.event-wrapper h1 {
    display: block;
    margin: 1rem;
    margin-bottom: 0rem;
    padding: 0;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: left;
    color: black;
}
.event-text {
    float: left;
    margin-top:.5rem;
    width: 80%;
}

Please note that the website is in the early alpha stage of development. 请注意,该网站处于开发的早期Alpha阶段。

Instead of Float try position: relative; 代替Float试试position: relative; and use margin for placing it on the required place where you want 并使用边距将其放置在所需的所需位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM