Text floating in block next to image

前端 未结 5 1372
余生分开走
余生分开走 2020-12-08 20:03

I would like to achieve the following placement:

Two different texts (in block) floating / inline next to image. (Everything inside div).

I have been trying

相关标签:
5条回答
  • 2020-12-08 20:08

    well you can try the classic way using tables although it is not recommended to use tables for layout

    <table>
      <tr>
        <th><img src="yourimage" /> </th>
        <th >adsasd<br/>adas</th>
      </tr>
    </table>
    
    0 讨论(0)
  • 2020-12-08 20:14

    .content {
        width: 400px;
        border: 4px solid red;
        padding: 20px;
        overflow: hidden;
    }
    
    .content img {
        margin-right: 15px;
        float: left;
    }
    
    .content h3,
    .content p{
        margin-left: 15px;
        display: block;
        margin: 2px 0 0 0;
    }
    <div class="content">
        <img src="http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png"/ alt="" >
        <h3>Title</h3>
        <p>Some Description</p>
    </div>​

    0 讨论(0)
  • 2020-12-08 20:18

    I think you need the following:

    HTML:

    <div class="wrap">
      <img src="img.jpg" class='left;' />
      <h1 class='right'>TITLE</h1>
      <div class='right'>Element description</div>
    </div>
    

    CSS:

    .wrap { width: 600px; /* Just a sample value */ }
    .left { width: 200px; float: left; }
    .right { margin-left: 220px; width: 380px;}
    

    That should do the trick. Adjust width and margin params to your needs.

    0 讨论(0)
  • 2020-12-08 20:25

    Hi why used to float left you can do this without used float as like this

    <div class="res">
    <img src="<?php echo 'img/'.$row["sType"].'.png';?>"/>
    <div class="text"><h5>TITLEe</h5>
      <p>Description</p></div>
    </div>  
    

    Css

        .res {
        height:60px;
        background-color:yellow;
        border-bottom:1px solid black;
    }
    img, .text{
    vertical-align:top;
    }
    .text{
    display:inline-block;
    }
    p, h5{
    margin:0;
      padding:0;
    }
    

    Live demo

    and change to css, class according to your design

    0 讨论(0)
  • 2020-12-08 20:34

    try this.....should work

    html:

    <div id="testDiv">
        <div class="imgContainer"><img src="path/image.jpg" /></div>
        <div class="textContainer"></div>
    </div>
    

    css:

    #testDiv { float:left; width: 360px; }
    #testDiv .imgContainer { float:left; width:120px; height:90px; }
    #testDiv .textContainer { float:left; width:240px; height:90px; overflow:hidden }
    
    0 讨论(0)
提交回复
热议问题