html - How to create a div with 2 columns for text and image icon? -
there following code:
<?php foreach ($data $vacancy) { ?> <div class="vacancy"> <img src="<?php echo yii::app()->request->baseurl; ?>/images/vacancy_icon.jpg" /> <div class="name"> <?php echo chtml::link($vacancy['name'], array('vacancy/show', 'id'=>$vacancy->vacancy_id)); ?> </div> <div class="info"> <div class="public_date">public date: <?php echo $vacancy['date']; ?></div> </div> <hr /> </div> <?php } ?>
as can see, each "vacancy" contains 2 columns text , 1 image. there styles:
.vacancy img { float:left; width: 50px } .vacancy .name { margin: 0; width: 50px; } .vacancy .info { float: right; width: 50px; }
i need each vacancy visible in following order: icon, "name", "info", looks that:
how can fix it?
updates:
now code is:
<?php foreach ($data $vacancy) { ?> <div class="vacancy"> <div class="img"> <img src="<?php echo yii::app()->request->baseurl; ?>/images/vacancy_icon.jpg" /> </div> <div class="name"> <?php echo chtml::link($vacancy['name'], array('vacancy/show', 'id'=>$vacancy->vacancy_id)); ?> </div> <div class="info"> <div class="public_date">public date: <?php echo $vacancy['date']; ?></div> </div> </div> <?php } ?>
css:
.vacancy { width: 100%; } .vacancy .img { float : left; margin-left:10px; display-inline:block; } .vacancy .name { float : left; margin-left:10px; display-inline:block; } .vacancy .info { float : left; margin-left:10px; display-inline:block; }
answer: right styles:
.vacancy { width: 100%; float:left; display:block; } .icon { float : left; margin-left:10px; } .name { float : left; margin-left:10px; } .info { float : left; margin-left:10px; }
but there next trouble - how can align text in .name , .info vertically?
if want on same line.
.vacancy { width: 100%; float: left; display: block; } .img { float : left; margin-left:10px; display:inline;} .name { float : left; margin-left:10px; display:inline;} .info { float : left; margin-left:10px; display:inline;}