I have started a new project today in HTML and CSS trying to use and understand a bit more of Flexbox. This is the pen I am working with for now:
My question is: How can I have the picture on the left hand side and the paragraph right next to it, possible centred to the image level? Is flexbox what I have to use to obtain this? Or bootstrap is the best option? I am quite new to all this frameworks and I dont know yet which one is better for which project.
and you should set an id attribute to div, which contains your img and p tags. Then declare it as a flex container using this:
display: flex;
image will become stretched, because ‘align-items’ default is stretch, because of this set align-items to center. this will center the items horizontally.
Oh wow! That was great!! Thanks!
Can you explained me why it worked? The display: flex property tell all the element in the div to occupy all the space in equal parts?
When you add display: flex to an element, the items within the element are packed towards the start by default.
If you want to space the elements in equally, you can use justify-content: space-evenly; on the flex container (the same div you put display: flex on).
No, I dont really understand it still because it is honestly my first ever approach to it and I am trying to understand it doing it, more than simply reading I am trying to do both, being practical and looking for explanation when I do not understand.