gpt4 book ai didi

html - float right 中的文字显示在左侧

转载 作者:可可西里 更新时间:2023-11-01 14:53:13 25 4
gpt4 key购买 nike

我在显示以下代码时遇到了问题。我关心的是划分 <div class="contectCode">到两个<div class="left"><div class="right"> .所以,有些switch的情况应该显示在左边,有些应该显示在右边。

<?php

$xml = simplexml_load_file("Profiles.xml");

foreach($xml->children() as $Developer){
echo '<div class="contectCode" style="height: 260px;">';

echo '<div class="left" style="width:365px;">';
echo '<b>' . $Developer['name'] . '</b>';
echo '</div><br/>';

echo '<div class="left" style="width:365px; float:left; text-align:left;">';
echo '<p><b><i>Communications with you</i></b></p>';
echo '</div>';

echo '<div class="right" style="width:365px; float:right; text-align:left;">';
echo '<p><b><i>Communications with other developers </i></b></p>';
echo '</div>';
foreach($Developer->children() as $factor){

switch ($factor->getName()){

case "trust":
echo '<div class="left" style="width:365px; float:left; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>You have selected (trusted) him to help you ' . $factor . ' times</p><br/>';
else
echo '<p>You have selected (trusted) her to help you ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "response":
echo '<div class="left" style="width:365px; float:left; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He hes responded to your help request ' . $factor . ' times</p><br/>';
else
echo '<p>She has responded to your help request ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "indegreeOutdegree":
echo '<div class="left" style="width:365px; float:left; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has helped you to complete your code ' . $factor . ' times</p><br/>';
else
echo '<p>She has helped you to complete your code ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "recommended":
echo '<div class="left" style="width:365px; float:left; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has been recommended to you by others ' . $factor . ' times</p><br/>';
else
echo '<p>She has been recommended to you by others ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "trustG":
echo '<div class="right" style="width:365px; float:right; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has been selected (trusted) by others ' . $factor . ' times</p><br/>';
else
echo '<p>She has been selected (trusted) by others ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "responseG":
echo '<div class="right" style="width:365px; float:right; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has responded to others requests ' . $factor . ' times</p><br/>';
else
echo '<p>She has responded to others requests ' . $factor . ' times </p><br/>';
echo '</div>';
break;
case "indegreeOutdegreeG":
echo '<div class="right" style="width:365px; float:right; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has helped other developers ' . $factor . ' times</p><br/>';
else
echo '<p>She has helped other developers ' . $factor . ' times</p><br/>';
echo '</div>';
break;
case "recommendedG":
echo '<div class="right" style="width:365px; float:right; text-align:left;">';
if($Developer['gender'] == "Male")
echo '<p>He has been recommended to help by others ' . $factor . ' times</p><br/>';
else
echo '<p>She has been recommended to help by others ' . $factor . ' times</p><br/>';
echo '</div>';
break;
}
}

echo '</div>';
}



?>

如果输出显示左侧和右侧 div 的案例,则效果很好。但是,如果输出显示右侧 div 中的案例,则会将它们移到左侧。我想在右边而不是在右边显示它们。

那么,我该怎么做呢?

CSS 是

.contectCode
{
font-size:15px;
line-height:24px;
margin-left:13px;
margin-right:13px;
border-style:solid;
border-width:2px;
border-color:#000066;
padding:10px;
margin-top:5px;
margin-bottom:10px;
}

.left
{
float:left;
width:60%;
}

.right
{
float:left;
}

最佳答案

怎么样:

.right
{
float:left;
text-align:right;
}

关于html - float right 中的文字显示在左侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14823643/

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