gpt4 book ai didi

html - 我怎样才能使 iframe 居中,同时让它内联显示?

转载 作者:太空宇宙 更新时间:2023-11-04 13:17:34 25 4
gpt4 key购买 nike

我有一个 youtube 视频,我想将它放在一个 div 中。我已经添加了

display: block;

按照此处建议的 css How to center an iframe horizontally?它确实正确居中。但是,我有两张图片我想在 iframe 旁边显示,一张在左边,一张在右边。问题当然是当我在 iframe 中设置 display: block 时,它阻止了图像被放置在图片的左侧和右侧。

这是html

<div class="content">

<a id="logo" href="http://www.example.com">
<img id="logo" src="img/logo.png" alt="logo">
</a>
<br>

<nav class="topNav">
<a href="index.html">
<img id="home" class="topNav" src="img/home.png"
alt="home">
</a>
<a href="photos.html">
<img id="photos" class="topNav" src="img/photos.png"
alt="gallery">
</a>
<a href="about.html">
<img id="about" class="topNav" src="img/about.png" alt="about">
</a>
</nav>
<br>

<
<img id="image1" src="img/image1.png" alt="img1">
<iframe id="video" src="http://www.youtube.com/embed/L-9y6jP-HO4">
</iframe>
<img id="image2" src="image2.png" alt="img2">

<br>

<a id="downloadmp3" href="mp3/poo-on-the-shoe-ringtone.mp3"
target="_blank" onmouseover="mOver()" onmouseout="mOut()">
Download the ringtone!
</a>
<br>

<a href="https://www.facebook.com"
target="_blank">
<img id="facebookPic" src="img/facebook.png"
alt="Like Us On Facebook">
</a>

这是CSS

body {
background: #563C21;
text-align: center;
}

.content {
text-align: center;
background-color: #4D361E;
box-shadow: 0 0 150px black;
border-radius: 15%;
}

#logo {
margin: auto;
text-decoration: none;
}

.topNav {
width: 210px;
height: 50px;
margin: auto;
display: inline;
}

.topNav a {
text-decoration: none;
}

#video {
width: 540px;
height: 315px;
display: block;
margin: auto;
border: 0;
}



如何使 iframe 居中,同时保持图像的内联行为?

最佳答案

示例链接:http://jsfiddle.net/BeEg9/

CSS:

 #video {
width: 540px;
height: 315px;
margin: auto;
border: 0;
display: inline;
}

#image1, #image2 {
height: 200px;
display: inline;
}

.content {
text-align: center;
display: block;
}

HTML:

<div class="content">
<img id="image1" src="img/image1.png" alt="img1" />
<iframe id="video" src="http://www.youtube.com/embed/L-9y6jP-HO4">
</iframe>
<img id="image2" src="image2.png" alt="img2" />
</div>

关于html - 我怎样才能使 iframe 居中,同时让它内联显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24313653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com