gpt4 book ai didi

css - float 如何用于定位列?

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

此处如何使用 float 将联系信息栏定位在照片下方。我大部分时间都在向左漂浮,但我想知道如何将最后的联系信息贴在图片上。

enter image description here

这是我希望它向上移动的地方,但我无法这样做。这是当前设置:

<div id='post'><div id='vpPhotos'>
<img src='Images/img.jpg'/><img src='Images/default.png'/><img src='Images/default.png'/><img src='Images/default.png'/></br><a id='posttitle' href='#?photoID=$photoID'>View More Pictures</a>
</div>
<div id='vpTitle'>
<h3>$eventTlt</h3>
</div>
<div id='vpprice'><b>Price: </b>$priceOfEvent</div>
<div id='vpdate'>
</br><b>Start Date:</b> <div class='float-right'>$eventSD </div>
</br><b>End Date:</b> <div class='float-right'>$eventED</div>
</br><b>Start Time:</b> <div class='float-right'> $eventTime </div>
<br/><b>Location Of Event:</b> <div class='float-right'>$location</div>
<br/><b>Address Of Location:</b> <div class='float-right'>$locationAddress</div></div>
<div id='eventdesc'>
</br></br><b>Description:</b> &nbsp&nbsp$eventDesc </div>
<div id='vpcontact'>
</br><h3 align='left'><b>Contact Information</b></h3> &nbsp&nbsp
</br><b>Name:</b> &nbsp&nbsp$contactName
</br></br><b>Email:</b> $emailAddress</div>


<div style='clear:both;'/>
</div>

我正在向左漂浮。在我所有其他 div 都向左浮动之后,我不确定那是正确的。 #post是最外层的,其他的基本上都是用名字来形容的。

#post{
border:3px inset red;
margin-right:20px;
}
#vpPhotos{
border:3px outset blue;
float:left;
width:25%;
}
#vpTitle{
float:left;
border:3px inset green;
}
#vpdate{
float:left;
width: 20%;
border:3px inset blue;
margin-right:100px;
padding-right:300px;
}
#eventdesc{
float:left;
width: 73.74%;
border:3px inset green;
}
#vpcontact{
float:left;
width: 24%;
border:3px inset red;
}
#vpprice{
float:right;
width: 15%;
border:3px inset black;
}

最佳答案

为此,您需要将照片和联系人 div 放在一个单独的 div 中,将其 float 并将所有其他 div 放在另一个也 float 的 div 中。

Working example on JS Bin .

更新代码:

HTML:

  <div id='post'>
<div id='column-one'>
<div id='vpPhotos'>
<img src='Images/img.jpg'/><img src='Images/default.png'/><img src='Images/default.png'/><img src='Images/default.png'/></br><a id='posttitle' href='#?photoID=$photoID'>View More Pictures</a>
</div>
<div id='vpcontact'>
<h3 align='left'><b>Contact Information</b></h3> &nbsp&nbsp
</br><b>Name:</b> &nbsp&nbsp$contactName
</br></br><b>Email:</b> $emailAddress
</div>
</div>

<div id="column-two">
<div id='vpTitle'>
<h3>$eventTlt</h3>
</div>
<div id='vpprice'><b>Price: </b>$priceOfEvent</div>
<div id='vpdate'>
</br><b>Start Date:</b> <div class='float-right'>$eventSD </div>
</br><b>End Date:</b> <div class='float-right'>$eventED</div>
</br><b>Start Time:</b> <div class='float-right'> $eventTime </div>
<br/><b>Location Of Event:</b> <div class='float-right'>$location</div>
<br/><b>Address Of Location:</b> <div class='float-right'>$locationAddress</div></div>
<div id='eventdesc'>
</br></br><b>Description:</b> &nbsp&nbsp$eventDesc </div>
</div>

<div style='clear:both;'/>
</div>

CSS:

#post {
border: 3px inset red;
margin-right: 20px;
}

#column-one,
#column-two {
float: left;
width: 24%;
}

#column-two {
width: 76%;
}

#vpPhotos {
border: 3px outset blue;
width: 98%;
float: left;
}

#vpTitle {
float: left;
width: 80%;
border: 3px inset green;
}

#vpdate {
width: 99%;
float: left;
border: 3px inset blue;
}

#eventdesc {
float: left;
width: 99%;
border: 3px inset green;
}

#vpcontact {
float: left;
width: 98%;
border: 3px inset red;
}

#vpprice {
float: right;
width: 15%;
border: 3px inset black;
}

关于css - float 如何用于定位列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14805511/

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