简体   繁体   中英

How to place Image and Text next to another Image in HTML/CSS?

I am trying to place Image and Text next to another Image. If you want to see what I mean, look here:

7xecD

I tried using floats and stuff, but It doesn't seem to work. Here is my code:

.left {float: left;}
.right{float: right;}

<div class="left">
<img src="img/image1.png" />
<p>Text</p>
</div>

<div class="right">
<img src="img/image2.png" />
</div>

Is this what you want?

<body>


<div id="Menu">
<img src="image"/>
<h4>Text</h4>


 </div>


 <div id="Container">
 <h4>Content Section</h4>


 </div>



 body, html {
 width:100%;
 height:100%;
 margin:0;
 color:white;
 }


 #Menu  {
 background-color:black;
 height:50%;
 width:25%;
 position:relative;
 top:70px;
 float:left;
  }

 #Container {
 height:50%;
 width:70%;
 background-color:blue;
 position:relative;
 top:70px;
 float:right;

 }

Here you go,

.container {
    width:100%;
    height:500px;
}

.left, .right{
    position:relative;
    height:100%;
    width:50%;
    float:left;
}

.img1{
    width:100%;
    height:50px;
}


<div class='container'>
    <div class="left">
        <img src="http://www.ancestry.com/wiki/images/archive/a/a9/20100708215937!Example.jpg" alt="img 1" class='img1'/>
        <p>asdf asfd asdf asdf</p>
    </div>
    <div class="right">
        <img src="http://www.ancestry.com/wiki/images/archive/a/a9/20100708215937!Example.jpg" alt="img 1" />
    </div>
</div>

http://jsfiddle.net/qCGuL/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM