I am quite new to CSS and HTML so I am having trouble with aligning two divs next to each other.
This is my HTML:
<!DOCTYPE html>
<html>
<head>
<title>cards</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<div id="card_container">
<div id="card_image_container">
<img src="https://openclipart.org/image/2400px/svg_to_png/177482/ProfilePlaceholderSuit.png"/>
</div>
<div id="card_content_container">
<div id="card_content_title">
<h1>ADVERT</h1>
<h2>EXAMPLE
</div>
<div id="card_content_text">
<p>
<b>Heading</b><br/>
Info
</p>
<p>
<b>Heading 2</b><br/>
Info 2
</p>
</div>
<div id="card_content_actions">
</div>
</div>
</div>
</body>
</html>
and this is my CSS:
*{
padding: 0px;
margin: 0px;
}
#card_container{
margin-left: auto;
margin-right: auto;
width: 36%;
margin-top: 10%;
border: 1px solid grey;
}
#card_container > div{
display: inline-block;
}
#card_image_container{
width: 40%;
background-color: green;
}
#card_image_container img{
vertical-align: bottom;
width: 100%;
height: 100%;
}
#card_content_container{
vertical-align: top;
background-color: red;
width: 59%;
}
And this is the problem I have:
As you can see - my div has white spaces around it, I know this is due to 1% of width left over but if I change my:
#card_content_container{
vertical-align: top;
background-color: red;
width: 59%;
}
width to 60%, the content_container gets moved to next line.
I need card_content_container to fill the remaining 60% so it's aligned perfectly.
Here is js fiddle: