gpt4 book ai didi

html - 如何控制图像在 div/in CSS 中的位置?

转载 作者:行者123 更新时间:2023-11-28 14:41:22 26 4
gpt4 key购买 nike

我目前正在尝试自学 HTML。现在我只是为了美观而创建一个网站,但我在使用 CSS/div 时遇到了麻烦。目前它看起来像this .没有 h1,它实际上就在文本旁边。我的代码如下所示:

<!Doctype html>
<html>


<title>Lovey Lovey</title>


<head>

<link rel="shortcut icon" href="https://www.emoji.co.uk/files/phantom-open-emojis/symbols-phantom/12944-sparkling-heart.png" />

<link rel= "stylesheet" type="text/css" href="love.css">

<style type="text/css">


body {background: url("https://media.giphy.com/media/elf1s7iKPGXks/giphy.gif") #ffb3ff right repeat; }

</style>

</head>


<body>

<center>

<img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" > <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" > <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" >

<br>
<br>


<div class = "header">
<img src= https://i.imgur.com/7Xjrk3X.gif alt= "Left" style= "height:75px; width:75px; float:left;">


<h1>I love you!</h1>

<img src= https://i.imgur.com/CQl7GZu.gif alt= "Right" style= "float:right; height:75px; width:75px;">

</div>

<br>

<h2><i>Love you so much!</i></h2>

<br>
<br>
<br>

<img src = https://i.imgur.com/HCwaPsi.gif height="170" width="140" />

<br>
<br>

<img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" > <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" > <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif/revision/latest?cb=20171010223602 height= "75" width= "75"> <img src= https://vignette.wikia.nocookie.net/animal-jam-clans-1/images/a/a3/Tumblr_static_971v84xme8g888gwwow800cc0.gif height= "75" width= "75" >

最后我的 CSS 看起来像这样:

@charset "utf-8";
/* CSS Document */

.header Left {
float: left;
width: 100px;
height: 100px;
background: #555;
}

.header Right {
float: right;
width: 100px;
height: 100px;
background: #555;
}

.header h1 {
position: relative;
top: 18px;
left: 10px;
}

基本上,我想做的是在“我爱你!”旁边添加翅膀。同时仍然让文本变大。我觉得我真的在 CSS 中遗漏了一些东西,但我不完全确定。感谢你们提供的任何意见!

最佳答案

您可以像这样同时提供 imgs 和 ID:

<img src="..." id="left-wing" />
<img src="..." id="right-wing" />

对于 CSS:

img#left-wing {
position: absolute;
top: 50vh;
left: 40vh;
}

img#right-wing {
position: absolute;
top: 50vh;
left: 60vh;
}

我不确定这些尺寸是否有效,但试一试,您会把它们放在它们应该在的地方。

关于html - 如何控制图像在 div/in CSS 中的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52885430/

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