Had to do this using inline styles to override stuff in the stylesheet etc
<div class="responsive-container" style="display: flex; flex-wrap: wrap; align-items: flex-start; margin-top: 0px; margin-bottom: 0rem;">
<div class="text-container" style="flex: 1; min-width: 0; margin-right: 20px;">
<h3 style="margin-bottom: 0.4rem;">FIFA Basic</h3>
<p>
Gyda nod ansawdd FIFA Basic, mae Pêl-droed Clwb FORZA yn opsiwn cost-effeithiol ar gyfer timau pêl-droed o bob lefel ar gyllideb. Ar gael mewn meintiau 3, 4, a 5, mae'r peli hyn yn addas ar gyfer pob oed. Mae'r bledren butyl wedi'i amgylchynu gan chwe phanel wedi'i wasgu â gwres gyda deunydd polywrethan 1.2mm o drwch, i helpu'r bêl i gadw ei siâp ar ôl effeithiau dirifedi, yn ogystal â gwneud y bêl-droed o ansawdd gêm yn gwrthsefyll rhwyg ac yn gwrthsefyll y tywydd ym mhob cyflwr. Mae Pêl-droed Clwb FORZA ar gael mewn pecynnau o naill ai 1, 3, neu 30 pêl, ac mewn dau gyfuniad lliw (Gwyn a Glas neu Gwyn a Phinc).
</p>
</div>
<img class="responsive-image" src="https://nwscdn.com/media/wysiwyg/buyersguide/FIFA-Basic-Logo.png" style="max-width: 100%; flex-shrink: 0; width: 250px; align-self: flex-start;">
</div>
<style>
@media (max-width: 768px) {
.responsive-container {
flex-direction: column;
}
.text-container {
margin-right: 0;
}
.responsive-image {
width: 100%;
max-width: 100%;
margin-top: 20px;
align-self: center;
}
}
</style>
Obviously, you probably want to change the parapraph text in the <p> and </p> tags and the header in <h3> tags and the image URL
I couldn’t do it all with inline styles in the end – media query had to be put in <style> tags in the HTML doc.
If you’re using a normal webpage – you want the style tags in the <head>
On screens that are 768px or less (i.e. mobile phones), The “name-of-div-container” should be positioned relative with no transform styling.
This is quite specific code for the example I was using but you can replace position relative and transform none with whatever you want the element to do on a mobile device.
If you want to put text underneath an image that “floats” to the left (or right), you can use this code:
<div style="margin-bottom:0;">
<div style="float: left;">
<img src="https://nwscdn.com/media/wysiwyg/FORZA/MenHandballSize_Chart2.png" style="width: 700px;" alt="mens & boys handball size by age"/>
</div>
<div style="clear: both;">
text text text
</div>
</div>
For personal reference, this is the code I need with the correct class for my website:
<div class="content-item" style="margin-bottom:0;">
<div style="float: left;">
<img src="https://nwscdn.com/media/wysiwyg/FORZA/MenHandballSize_Chart2.png" style="width: 700px;" alt="mens & boys handball size by age"/>
</div>
<div style="clear: both;">
text text text
</div>
</div>
Margin:auto – will automatically center align your element:
“Auto margin is used by Apple, Google, Stripe, and other design leaders as a way to horizontally center elements. By setting auto margin to an element that has a defined width, you can horizontally center the element within the boundary of its parent.”
TLD;R – I just set everything in “rem” units instead of pixels and it keeps padding etc relatively-relative on all devices
First – you may want to use “padding-block:” – which is the padding for the top and the bottom only.
You can also use a “min()” statement or line of code, or whatever it’s called in CSS
If you type:
section {
padding-block: min(10vh, 10rem)
Min, Max & Clamp
Min
To use “min” – you may for example have a back-ground colour, with width:70% and max width:500px
width: min(500px, 70%)
Min will “look” for the smallest value – either 500px, or 70%
Min will choose the smallest value.
If you are on a mobile for example, 70% width, is less than 500px – so on mobile the background will be 70% of the viewport for a mobile.
If you are on a desktop computer, 500px will be less than 70% of the screen width – so the background will be 500px wide.
Responsive Equal Padding Top & Bottom
If you wanted to pad the top and bottom of text in the background:
padding-block: min (30px; 10%) ;
Max
width: max(500px, 70%)
max is the opposite – now it will use the maximum value.
on Mobile, 500px will be the largest
On Desktop – 70% will be the largest.
Padding with a Percentage
Calc Rem + VW
Yet another way to add padding, is to use “calc” and then add parameters/values for rem and vw
Rem (short for “root-em”) units dictate an element’s font size relative to the size of the root element. By default, most browsers use a font size value of 16px.
The full form of VW is viewport width. It works like the percentage unit. Specifying 10vw is equivalent to occupying 10% of entire visible screen width.
flex:1 – for each of the boxes, makes them evenly distributed in terms of their width. As all the flex items are given a value of 1, they are all the same size.
If you were to change the flex value for .box-1 to 4, then box-1 would take up four-sixths (4/6) of the page:
Change the order of Flex Items
With flexbox you can change the order of the flex-items, (the boxes) without changing the HTML.
To do this use the “order” property.
The code below will put box-1 in the second position, left to right.
Flex-direction: Column
By giving the container the flex-direction property, with a value of “column”, the boxes / flex items will stack on top of each other
Justify-Content
You can use the “justify-content” property to align the boxes within the flex container.
justify-content: flex-end; will push all the flex items to the right
Justify-content:center; will place the boxes in the centre of the container
Justify-content:space-between;
Aligns the content spaced evenly across the entire width of the container, with margins in between:
Space-around will add some “space around” the items, so that they have margins in between the items and also to the sides of the left-most and right-most items:
Flex Grow
If after the dimensions of the flex-items have been set, they leave room or space, you can use the “flex-grow” property.
If you give each flex item a flex grow value of 1, then the items will take up an equal amount of the remaining space.
It could be 1, or 100, it won’t make a difference if all the items have the same value.
Below, flex item “one”, is the only flex item with a “flex grow” property, and it therefore takes up all the space that was left over from left to right by the 3 boxes.