我有一個問題,需要一個答案。我如何自動將2個圖像水平放置。如何水平顯示兩個圖像?
我想我會用一些if(1 ==%3)? 在這個例子中,我真的很喜歡橫向2個圖像不知道該怎麼做?
這裏是我做了什麼:
for($i=0; $rows = $results->fetch(); $i++){
if($dsds=='Commissoner'){
echo $rows['prog_id'].$rows['prog_id'].' '.$rows['prog_name'].' = '.$rows['votes'];
}else {
//this is the part where I put a css
style='margin-left:44px;'><div class='box_img2' style='margin-right:10px;' >";
echo '<img src="candidates/images/'.$rows['image'].'" width="70" height="80px" />'.', '.'<br>'.$rows['lastname'].', '.$rows['firstname'].'<br>'.' = '.$rows['votes'];
echo '<br>';
}
$sdsd=$dsada
?>
<img src="candidates/images/percent.gif"width='<?php echo(100*round($rows['votes']/($sdsd),2)); ?>'height='10'>
<?php
if ($rows['votes']==0){
echo "<br>";}
else {
echo(100*round($rows['votes']/($sdsd),2)); ?>%<br>
<?php
}
echo '</div>';
}
?>
這裏是我的CSS:
.row:before, .row:after { clear:both; }
.row{
display: block;
}
.box_img2 {
float: left;
/*margin-right:85px;*/
text-align:center;
}
.box_img2 img { /* if you want it centered */
display:block;
display: inline-block;
}
這裏是我的全部代碼:
<?php
include('../connection/connect.php');
$result = $db->prepare("SELECT * FROM candposition ORDER BY posid ASC");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
$dsds=$row['posid'];
$resulta = $db->prepare("SELECT sum(votes) FROM candidates WHERE posid= :a");
$resulta->bindParam(':a', $dsds);
$resulta->execute();
for($i=0; $rowa = $resulta->fetch(); $i++){
$dsada=$rowa['sum(votes)'];
}
echo '<div style="margin-top: 18px;">';
echo '<strong>'.$row['pos_name'].' '.'</strong><br>';
$results = $db->prepare("SELECT * FROM candidates,student WHERE candidates.idno=student.idno AND candidates.syearid = '$no'AND posid = :a ORDER BY votes DESC");
$results->bindParam(':a', $dsds);
$results->execute();
for($i=0; $rows = $results->fetch(); $i++){
if($dsds=='Commissoner'){
echo $rows['prog_id'].$rows['prog_id'].' '.$rows['prog_name'].' = '.$rows['votes'];
}else {
//this is the part
echo'<?php $src=array("candidates/images/".$rows["image"]); for($i=0;$i<3;$i++){ ?>';
echo '<img src="candidates/images<?php echo .$src[$i];?>" class="image-inner" />';}
$sdsd=$dsada
?>
<!-- <img src="candidates/images/percent.gif"width='<?php echo(100*round($rows['votes']/($sdsd),2)); ?>'height='10'>-->
<?php
if ($rows['votes']==0){
echo "<br>";}
else {
// echo(100*round($rows['votes']/($sdsd),2));/
/*?>%<br>*/
/*<?php
}
echo '</div>';*/
}
}
?>
<?php
}
?>
只要給 '位置:相對;'在CSS中,並給圖像一些寬度 –
我應該在那裏放置?在排隊? – miming
這裏是你的小提琴.. https://jsfiddle.net/adarsmohan76/cdvsw8hz/ –