浮动不起作用。更改边距不起作用。互联网上根本没有将两个HTML元素彼此相邻放置。
<body>
<section id="slideshow">
<div id="slide">
<h3>Hello World</h3>
<img id="slide-image" src="https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png" alt="">
</div>
</section>
</body>
我只希望此标题与图片位于同一行。
答案 0 :(得分:-1)
您可以将显示flex
添加到.slide
或将inline-block
添加到h3
和img
.slide {
display: flex;
align-items: center;
}
img {
width: 200px;
height: 200px;
}
.slide2 > * {
display: inline-block;
}
<div class="slide">
<h3>Hello World</h3>
<img id="slide-image" src="https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png" alt="">
</div>
<div class="slide2">
<h3>Hello World</h3>
<img id="slide-image" src="https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png" alt="">
</div>