gpt4 book ai didi

html - 如何使用 HTML 和 CSS 正确右对齐文本以显示在图像旁边

转载 作者:行者123 更新时间:2023-11-28 13:54:28 25 4
gpt4 key购买 nike

在我因类似问题被否决或标记之前,我搜索了堆栈但需要澄清,因为我是网页设计的初学者并且在完全理解行话时遇到一些问题。对于背景,我正在创建一个个人资料页面,其中用户图片位于屏幕左侧,图片右侧应该是一段包含滚动条的信息。我使用了一个 div,我得到了滚动条,但它直接出现在图像下方。我需要它在它旁边。我尝试使用类、填充和边距来尝试将其居中,但我无法移动小节或 div 本身。类似于此 ( http://blogs.bournemouth.ac.uk/research/files/2013/09/SPP1.jpg ),但信息显示在图像的正右侧。请原谅我这个冗长的问题,但我希望我对我的问题已经足够清楚了。谢谢。这是我的代码:

body {
background-color: rgb(5, 113, 176);
font-family: arial;
font-size: 15px;
}

h1 {
background-color: rgb(24, 48, 100);
color: #009999;
font-size: 2em;
}

h2 {
background-color: rgb(24, 48, 100);
color: #009999;
}

img {
filter: grayscale(1);
width: 150px;
}

.Scroll-Paragraph {
border: blue 8px solid;
width: 30%;
padding: 8px;
max-height: 100px;
overflow-y: scroll;
overflow-x: hidden;
}
<h1>Marzuq Mir</h1>
<ul>
Home|About Me|More
</ul>
<h1><b>Journey Through The Life of Marzuq</b></h1>
<img src="https://i.imgur.com/Tgqh5Hn.jpg?1" alt="A picture of Marzuq" />
<div class="Scroll Paragraph">
<h2>All About Marzuq Mir</h2>


<div class="Scroll-Paragraph">
<p>My Name is Marzuq Mir. I was born on November 11, 1980. I am an aspiring robot programmer with plans to go to MIT. I have an amazing mother and father and a loving brother. I currently go to middle school and i am gud at math. I love to play games
on my nintendo and spend my time running around the backyard of our mansion in upstate virginia. When I am bored from playing video games I go to my personal olympic sized pool and swim. After cooling off I read a book and draw up blueprints for
my future peace keeping robots which I hope will earn me the nobel peace prize.Finally to end the day I ride my BMX bike around the park while my dad rides with his Harley Davidson. My role model is Biil Gates. Microsoft is his crowning acheivement
but in my heart I know the acheivement that I gain from my robots will be comporable to that of Bill Gates. I might even become a multi biilionare and if I am lucky the worlds first multi-trillionare.</p>
</div>
<div class=:Scroll-Paragrah>
<h2>
My Favorite Foods to Eat
</h2>
<div class="Scroll-Paragrah">
<UL>
<br>
<li>Steak</li>
<br>
<li>Mash Potatoes</li>
<br>
<li>Chicken</li>
</UL>
</div>

最佳答案

将两者(图像和 block )放入另一个 div 中。将该 div 内的 img 设置为 float:left

<!DOCTYPE html>
<html>

<head>
<title>Marzuq's Bio</title>
</head>

<style type="text/css">
body{
background-color: rgb(5,113,176);
font-family: arial;
font-size: 15px;
}
h1{
background-color: rgb(24,48,100);
color: #009999;
font-size: 2em;
}
h2{
background-color: rgb(24,48,100);
color:#009999;
}
img{
filter: grayscale(1);
width: 150px;
}
.Scroll-Paragraph {
border:blue 8px solid;
width:30%;
padding: 8px;
max-height:100px;
overflow-y:scroll;
overflow-x:hidden;
}
.wrap-around img {
float:left;
}



</style>

<body>
<h1>Marzuq Mir</h1>
<ul>
Home|About Me|More
</ul>
<h1><b>Journey Through The Life of Marzuq</b></h1>

<div class="Scroll Paragraph"><h2>All About Marzuq Mir</h2>
<div class="wrap-around">
<img src="Marzuq2.jpg"alt="A picture of Marzuq"/>

<div class="Scroll-Paragraph"><p>My Name is Marzuq Mir. I was born on November 11, 1980. I am an aspiring robot programmer with plans to go to MIT. I have an amazing mother and father and a loving brother. I currently go to middle school and i am gud at math. I love to play games on my nintendo and spend my time running around the backyard of our mansion in upstate virginia. When I am bored from playing video games I go to my personal olympic sized pool and swim. After cooling off I read a book and draw up blueprints for my future peace keeping robots which I hope will earn me the nobel peace prize.Finally to end the day I ride my BMX bike around the park while my dad rides with his Harley Davidson. My role model is Biil Gates. Microsoft is his crowning acheivement but in my heart I know the acheivement that I gain from my robots will be comporable to that of Bill Gates. I might even become a multi biilionare and if I am lucky the worlds first multi-trillionare.</p></div>
<div class=:Scroll-Paragrah><h2>
My Favorite Foods to Eat
</h2>
<div class="Scroll-Paragrah"><UL>
<br><li>Steak</li>
<br><li>Mash Potatoes</li>
<br><li>Chicken</li>
</div>
</UL>
</div>
</body>





</html>

关于html - 如何使用 HTML 和 CSS 正确右对齐文本以显示在图像旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58943542/

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