On this little project i can’t place paragraph on the right of the photo properly. There is big a mount of space between them.
I used display:flex
to place them horizontally. And width: 50%
to make them get half of the screen, but there is still field in the center….
Can someone help with solving this ?
What should i get:
I tried changing width 33%
, I’ve also tried adding padding and margin.
.center {
display: flex;
padding: 10px 10px;
background-color: #c2e7f0;
margin-top: 15px
}
.all {
display: flex;
padding: 20px;
}
.center img {
width: 60%;
float: left;
}
.text {
width: 50%;
font-weight: 100;
}
<div class="center">
<div class="all">
<div class="center_img">
<img src="g1.png">
</div>
<div class="text">
<h2>Khvicha Kvaratskhelia relishes ‘best day’ in Georgians’ lives</h2>
<p>Georgia is the lowest-ranked team at this year’s European Championship and few gave the nation a chance of progressing out of the group stages in what is its debut appearance at a major tournament.</p>
<p>But against all odds, the Crusaders produced a memorable performance to secure a deserved 2-0 Group F win against Portugal, thanks to a second-minute goal from Kvaratskhelia and a second-half penalty from Georges Mikautadze.</p>
<p>The coach, a vital cog in manager Willy Sagnol’s team, said the squad had been “calm” ahead of the crunch tie and managed to execute the game plan to perfection.Webb, known for his ability to motivate players on a more personal level, said he had
delivered a presentation before the tournament which focused on self belief.He said his speech drew on motivation from smaller nations, such as Wales and Iceland, which had punched above their weight at previous European Championships – Wales
reached the semifinals and Iceland the quarterfinals at Euro 2016.</p>
</div>
</div>
</div>
2
Answers
I noticed you had an extra
<div>
element surrounding the<img>
, causing the<img>
to be 60% of the width of the parentdiv
. Because of this, the image was not large enough to fit the entire box and thus there is extra space around it.To fix this, you could either remove the outer
div
, resulting in your HTML to be:or you could change the CSS to style the div to be 60%, whereas the image within to be 100% width, like below:
To place the paragraph on right side of the photo properly without any extra space between them, you can adjust the flex properties and ensure the widths of the elements are set correctly.
Please read the article – https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://www.w3schools.com/css/css3_flexbox.asp
Because flexbox understanding is good to do like this type of html arrangements.