Just starting out with HTML and CSS, I've run into some issues while writing my code. My goal is to have
- Text (on the left middle part) and image (on the right middle part) displayed side by side
- A responsive design that stacks the text on top of the image
Here are my questions:
- How can I align my image to the right so it lines up with the text on the left?
- Both text and image seem to be shifted downward.
- When resizing my browser, the layout becomes unresponsive and falls apart. How can I prevent this from happening?
Thanks in advance!
.first_section {
background-image:url('http://i347.photobucket.com/albums/p462/jimprince1990/zinc-white_zpsiibjtmdi.jpg');
background-position:center top;
background-size: cover;
padding: 200px 150px;
margin: 0 30px;
font-family: 'Trebuchet MS', 'Helvetica', 'sans-serif';
}
#first_section_text {
float: left;
text-align: left; /*Set everything to the left */
display: block;
width: 50%;
}
#first_section_image {
float: right; /* float property can be used to wrap text around images */
width: 50%;
height: 50%;
display: block;
}
<div class="first_section">
<div id="first_section_text">
<p>IT'S OFFICIALLY SANDWICHES SEASON</p>
<p>This summer, we've got more sandwiches options than ever. From the new mexican style to our classic chicken and beef sandwich, there's a style to fill you up on any hot day.</p>
<a href="navigation_bar/sub_menu/sandwiches.html">Explore now!</a>
</div>
<div id="first_section_image">
<img src="http://i347.photobucket.com/albums/p462/jimprince1990/Sandwiches_zps99hlhkod.jpg" height= "235" width= "235"/>
</div>
</div>