How to keep two columns the same height with image? - html

We have a two column layout where image is on one side with text on the other. We want the image to be the same height as the content. We are having an issue when the text column reaches a certain height, then it will not make the image go full height. Although not added, this .flex__wrapper is surrounded by an outer <div class="container"> element so that we can handle larger screens where we may want to limit the width.
How can we achieve this? Our current solution uses flexbox, but we have also tried the following solutions but none resolves the problem.
Goal:
As the right column containing the text increases in height, i want the image to also take up the same amount of height.
Solutions we tried, but they didn't work. They seem to work well with text and text, but not text and image.
Make two columns the same height (using Flexbox)
Keep columns with same height
(using Tables)
.flex__wrapper {
display: flex;
position: relative;
align-items: center;
background-color: #eee;
}
[class*=col--] {
box-sizing: border-box;
}
.col--m-s-12 {
width: 100%;
}
.col--t-s-6 {
width: 50%;
}
img {
display: block;
height: auto;
}
<div class="flex__wrapper">
<div class="col--m-s-12 col--t-s-6">
<img src="https://thumb1.shutterstock.com/display_pic_with_logo/422872/1024946740/stock-photo-large-group-of-business-people-standing-with-folded-hands-togeth-1024946740.jpg">
</div>
<div class="col--m-s-12 col--t-s-6">
<div>Distinctively engineer timely benefits before leading-edge technology. </div>
<div>Quickly brand strategic web-readiness whereas global relationships. Credibly underwhelm interdependent e-markets via plug-and-play value. Professionally maximize emerging partnerships rather than equity invested information. Objectively morph intuitive applications rather than multimedia based best practices. Competently innovate covalent infrastructures after premium relationships.
Globally conceptualize holistic sources and leveraged synergy. Distinctively maintain stand-alone content without market-driven niche markets. Completely orchestrate seamless channels after high-quality synergy. Rapidiously scale cutting-edge niche markets with reliable innovation. Intrinsicly productize multifunctional manufactured products without high standards in e-tailers.</div>
</div>
</div>
Current issue:
Additional issue:
Desired result:

You need to apply max-width:100% on your image. Now even after applying the following style your image will not take whole place in full screen(1600*900px), this is happening because your original image is of less size(450*274) and the container where your are trying to fit is 792px approx. Try using a bigger image then it will be solved.
.flex__wrapper {
display: flex;
position: relative;
background-color: #eee;
flex-wrap: wrap;
}
#media screen and (min-width: 1024px) {
.flex__wrapper {
max-width: 56%;
}
}
[class*=col--] {
box-sizing: border-box;
flex-basis: 0;
flex-grow: 1;
max-width: 100%;
}
.col--m-s-12 {
width: 100%;
}
.col--t-s-6 {
width: 50%;
}
img {
height: 100%;
width: 100%;
object-fit:cover;
}
<div class="flex__wrapper">
<div class="col--m-s-12 col--t-s-6" style="border:solid 1px;">
<img src="https://thumb1.shutterstock.com/display_pic_with_logo/422872/1024946740/stock-photo-large-group-of-business-people-standing-with-folded-hands-togeth-1024946740.jpg" class="img-fluid">
</div>
<div class="col--m-s-12 col--t-s-6">
<div>Distinctively engineer timely benefits before leading-edge technology. </div>
<div>Quickly brand strategic web-readiness whereas global relationships. Credibly underwhelm interdependent e-markets via plug-and-play value. Professionally maximize emerging partnerships rather than equity invested information. Objectively morph intuitive
applications rather than multimedia based best practices. Competently innovate covalent infrastructures after premium relationships. Globally conceptualize holistic sources and leveraged synergy. Distinctively maintain stand-alone content without
market-driven niche markets. Completely orchestrate seamless channels after high-quality synergy. Rapidiously scale cutting-edge niche markets with reliable innovation. Intrinsicly productize multifunctional manufactured products without high standards
in e-tailers.</div>
</div>
</div>

html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test3</title>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
<main class="holder">
<section class="left-div">
<h1 class="flat-invisible">test-3</h1>
<img src="https://thumb1.shutterstock.com/display_pic_with_logo/422872/1024946740/stock-photo-large-group-of-business-people-standing-with-folded-hands-togeth-1024946740.jpg" alt="stock photo large group of business people standing with folded hands together">
</section>
<aside class="right-div">
<div>Distinctively engineer timely benefits before leading-edge technology. </div>
<div>Quickly brand strategic web-readiness whereas global relationships. Credibly underwhelm interdependent e-markets via plug-and-play value. Professionally maximize emerging partnerships rather than equity invested information. Objectively morph intuitive applications rather than multimedia based best practices. Competently innovate covalent infrastructures after premium relationships.
Globally conceptualize holistic sources and leveraged synergy. Distinctively maintain stand-alone content without market-driven niche markets. Completely orchestrate seamless channels after high-quality synergy. Rapidiously scale cutting-edge niche markets with reliable innovation. Intrinsicly productize multifunctional manufactured products without high standards in e-tailers.</div>
</aside>
</main>
</body>
</html>
css:
.left-div {
float: left;
grid-area: section;
max-width: 100%;
max-height: 100%;
}
.flat-invisible {
margin: 0em;
padding: 0em;
line-height: 0em;
height: 0em;
visibility: hidden;
}
.left-div > img {
object-fit: cover;
top: 0px;
height: 100%;
max-width: 120%;
}
.right-div {
padding-top: 2em;
padding-bottom: 2em;
padding-left: 150px;
max-width: 50%;
grid-area: aside;
max-height: 100%;
}
.holder {
max-width: 90%;
background-color: #eee;
display: grid;
grid-template:
'section aside';
}

Related

Flexbox: Two even columns - big image (with aspect-ratio) and content

I need to create an information section that includes an image and content next to it.
It should look like this:
I have already written a little bit of code, but it does not seem to be the best solution: everything works fine, but code is not graceful.
Please, have a look:
/* Simple reset */
img {
display: block;
max-width: 100%;
}
body {
background-color: black;
}
.information {
display: flex;
gap: clamp(5rem, 10vw, 8rem);
}
.information > * {
width: 50%; /* Using the 'width' property. */
}
.information-content {
align-self: center;
color: white;
}
.information-image {
align-self: flex-start;
object-fit: cover;
aspect-ratio: 1 / 1.10;
border-radius: 5px;
}
<section>
<div class="container">
<div class="information">
<img
class="information-image"
alt="Products for companies & Startups"
src="https://s3-alpha-sig.figma.com/img/6630/3672/40959a0086f9fbb8418c0829b277dd93?Expires=1670198400&Signature=gpQ5NqRXp9omRHkjCl718I9WPLqfx4xPKp1CQSMKbEnRCU7izmQIXkcn6zI6Z17p8Q7Li-wBAXb3P2Jg9qEuJauFeKqErbl4jgW950K35-LeX394hN7fJ7UEPmkgGSqB-drY1QdU7NZVV4QKTrZ0QBuw47xVBPOOfJMQO8NPOpZkx43UbbkS1yGgnxN5tELyriz9e8pH6pXO8AnJx7zvGz4mm3InyHOySUcb3ibVPa9XKJ8fyxPnkBeVoYFvwpiVddEs7uVNqCkCRuN2dJIIQg78FB-6TYX13nQ~NxvhG2059ks2q52a9p0N-DSmSYE-Yt-jedbJ1fEt3cZVnIfzUw__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
/>
<div class="information-content">
<h2>
My main goal is to keep my customers satisfied.
</h2>
<p>
Even with skills that are primarily mental, such as
computer programming or speaking a foreign language.
</p>
<p>
Even with skills that are primarily mental, such as
computer programming or speaking a foreign language.
</p>
</div>
</div>
</div>
</section>
My concern is the width property set on each child of my flex parent. As far as I know, using width inside flexbox is not the best idea? However, when I try to use the flex-basis property, everything breaks.
Note: I cannot use display: grid because the image can be after the content - with grid I will have to change the order and the code will become more complicated.

How can I space out the words in my navigation bar as well as turn all the text white?

I've tried to make a bar with not much success. I would like to space each of the three words "Main Page", "About Me" and Bibliography apart with each of them being in the left, center, and right respectively.
I'd also like to change the text of them so that they're white. Here is a sample of what it looks like now and my code below:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
}
h4 {
color: #00008B;
font-size: 2em;
}
h5 {
text-align: center;
}
body {
background-color: #FAFAFA;
}
.navigation {
color: #ffffff;
list-style-position:
box-sizing: border-box;
margin-left: 0;
padding: 0;
background-color: #000000;
}
.middle {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%
}
.footer {
color: #0000FF;
}
</style>
</head>
<body>
<h1>Main Page</h1>
<h5>Osirin bin Osiris</h5>
<nav>
<p class="navigation">
<a class="main" href="index.html">Main Page</a>
<a class="about" href="about.html">About Me</a>
<a class="biblio" href="bibliography.html">Bibliography</a>
<p>
</nav>
<h4>History of the Internet</h4>
<img src="ARPAnet.png" alt="ARPAnet diagram" length="607" width="490" class="middle">
<p> The modern day internet arose from the intranet developed by the U.S. military in 1969 (known as ARPAnet). Arpanet connected university computers across the country. It was restricted to sharing research material and was difficult to use.
Despite this, it was the essential foundation for the modern day internet that spans the globe. It’s important to note that the world wide web is not the same thing as the internet. The world wide web is a subset of the internet. It’s a collection of webpages containing images, videos, text, and sounds that are accessed using the http protocol. The best analogy to explain this difference would be to imagine a highway. The internet can be likened to a major highway and the world wide web are passenger car. There are many passenger cars that pass on the highway however; the highway contains more than just cars. It has trucks and vans travelling for business. In the same way, the internet isn’t just used by individuals but also governments, businesses and even satellites communicating with each other using different protocols.
</p>
<h4>How a page is delivered</h4>
<p> There are many things that need to work in order to bring a webpage to a device. These are:
<ul>
<li> Internet connection </li>
<li> Web browser </li>
<li> Server </li>
</ul>
<br>
When a person types in a web address, the operating system connects to a domain name server which will send back the I.P address that matches the text address to the user’s device. As the webpage appears, the user then interacts with the site by sending and receiving requests (i.e. clicking buttons, typing words, looking up images).
<br><br>
Information does not get communicated through the internet as it appears on a website. Instead, the browser breaks down texts, words, and images into small packets of information which are then sent from a computer/smartphone to the router, to a web server and then down fibre optic cables across the globe.
</p>
<footer>
<p class="footer"><b> </b></p>
</footer>
</body>
</html>
Many solutions. One solution would be to use flex box. Like that. You can add only this to your style:
.navigation {
display: flex;
}
.navigation a {
display: block;
width:33%;
text-align: center;
color: white;
}
working example
h1 {
text-align: center;
}
h4 {
color: #00008B;
font-size: 2em;
}
h5 {
text-align: center;
}
body {
background-color: #FAFAFA;
}
.navigation {
color: #ffffff;
list-style-position:
box-sizing: border-box;
margin-left: 0;
padding: 0;
background-color: #000000;
}
.middle {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%
}
.footer {
color: #0000FF;
}
.navigation {
display: flex;
}
.navigation a {
display: block;
width:33%;
text-align: center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<h1>Main Page</h1>
<h5>Osirin bin Osiris</h5>
<nav>
<p class="navigation">
<a class="main" href="index.html">Main Page</a>
<a class="about" href="about.html">About Me</a>
<a class="biblio" href="bibliography.html">Bibliography</a>
<p>
</nav>
<h4>History of the Internet</h4>
<img src="ARPAnet.png" alt="ARPAnet diagram" length="607" width="490" class="middle">
<p> The modern day internet arose from the intranet developed by the U.S. military in 1969 (known as ARPAnet). Arpanet connected university computers across the country. It was restricted to sharing research material and was difficult to use.
Despite this, it was the essential foundation for the modern day internet that spans the globe. It’s important to note that the world wide web is not the same thing as the internet. The world wide web is a subset of the internet. It’s a collection of webpages containing images, videos, text, and sounds that are accessed using the http protocol. The best analogy to explain this difference would be to imagine a highway. The internet can be likened to a major highway and the world wide web are passenger car. There are many passenger cars that pass on the highway however; the highway contains more than just cars. It has trucks and vans travelling for business. In the same way, the internet isn’t just used by individuals but also governments, businesses and even satellites communicating with each other using different protocols.
</p>
<h4>How a page is delivered</h4>
<p> There are many things that need to work in order to bring a webpage to a device. These are:
<ul>
<li> Internet connection </li>
<li> Web browser </li>
<li> Server </li>
</ul>
<br>
When a person types in a web address, the operating system connects to a domain name server which will send back the I.P address that matches the text address to the user’s device. As the webpage appears, the user then interacts with the site by sending and receiving requests (i.e. clicking buttons, typing words, looking up images).
<br><br>
Information does not get communicated through the internet as it appears on a website. Instead, the browser breaks down texts, words, and images into small packets of information which are then sent from a computer/smartphone to the router, to a web server and then down fibre optic cables across the globe.
</p>
<footer>
<p class="footer"><b> </b></p>
</footer>
</body>
</html>
this should get you going in the right direction, replace your .navigation rule with this and add the styles for link
.navigation {
color: #ffffff;
display: flex;
justify-content: space-between;
/*if you dont want the items to go all the way to the end*/
padding-left: 10px;
padding-right: 10px;
background-color: #000000;
}
.navigation a {
color: white;
}

Different response on different web browsers/screen size (not mobile friendly)

Honestly, I probably shouldn't even be writing right now given the fact that I am so heartbroken I just want to curl up in a ball and cry in bed. I have worked so hard SO FLIPPING HARD on my design/build and I was so proud of myself that I have not felt this happy in a long time. However, like reality vs. disney...all happy endings must crash and burn because life is no flipping disney screenplay.
Backstory:
I am a high functioning autistic who grew up in a REALLY flipping bad home. Cared for my mum since I was a child. Dad was an abusive piece of crud. We were really poor so I had to work 3 jobs since I was 8 just to take care of the house, bills, etc. Now mum is recently deceased, I am trying to get my life together and escape my abusive father. I can't afford college (because the "get a scholarship and apply for aid" is a load of cow manure), I can't afford bootcamps, I can't afford a mentor, so I taught myself to code using youtube, google and lots of reading.
After nearly two years of studying, many months of designing, many months of coding, trials and errors and research, I finally finished my portfolio website. I took one look at my masterpiece, bought my domain, and published my work. Right when I thought my life was about to change and that I was ready to apply for new jobs, I saw my beautiful sight that fits so beautifully on my chrome browser via macbook air and I asked myself "is this heaven" God instantly replied back "NO....THIS...IS...SPARTA..." and kicked my happy donkey all the way back to reality. Moral of the story, I am what my mummy called my ex's cooking...trash.
Here's my code please do not roast me like a pig at a nordic pagan festival. I am doing my best (which is clearly not good enough).
-----------------------------------website name------------------------------------------
arthurcurry.co.uk
yes this is my real name, yes I know who my mum named me after, yes I used this and my obsession with fish to create my site. Please do not start with the jokes fam. I have heard it my entire life. If you have no idea what I am speaking of... Congrats, you are the .01% of the world who most likely will not have a go at me because of it.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.pimg1,
.pimg2,
.pimg3 {
position: relative;
opacity: 0.70;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
.pimg1 {
min-height: 100%;
}
.pimg2 {
min-height: 400px;
}
.pimg3 {
min-height: 400px;
}
.pimg4 {
background-image: url('image4.jpg');
background-size: cover;
background-repeat: no-repeat;
min-height: 100%;
}
.section {
text-align: center;
padding: 50px 80px;
}
.section-light {
background-color: #f4f4f4;
color: #666;
}
.section-dark {
background-color: #282e34;
color: #ddd;
}
.ptext {
position: absolute;
top: 50%;
width: 100%;
text-align: center;
color: #000;
font-size: 27px;
letter-spacing: 8px;
text-transform: uppercase;
}
.ptext .border {
background-color: #111;
color: #fff;
padding: 20px;
}
.ptext .border.trans {
background-color: transparent;
}
#media(max-width:568px) {
.pimg1,
.pimg2,
.pimg3 {
background-attachment: scroll;
}
}
.info {
position: center;
}
.ptext4 {
position: absolute;
top: 450%;
width: 100%;
text-align: center;
color: #000;
font-size: 27px;
letter-spacing: 3px;
text-transform: uppercase;
}
.ptext4 .border {
background-color: #111;
color: #fff;
padding: 20px;
}
.ptext4 .border.trans {
background-color: transparent;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Arthur Curry</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="pimg1">
<video autoplay muted loop>
<source src="waves1.mp4" type="video/mp4" class="video1">
</video>
<div class="ptext">
<span class="border">
Designer. Developer. Conservationist.
</span>
<p>"What could be greater than a King? A Hero. A King fights for his nation, a hero fights for everyone." <strong> - Mera</strong></p>
</div>
</div>
<section class="section section-light">
<div class="text">
<h2> Who is Arthur Curry? </h2>
<p>
Many know his name but even more do not know who he truly is. Ever since Arthur Curry was a child, he felt himself drawn to the 7 seas and her despair as if she was physically calling to him. With the incapability to escape the grasp of her cries for
help, he knew something must be done. In 2016 he began teaching himself to code using numerous programming languages, text editors, design and developing platforms. Through his work he has made it his life mission to not just design and develop
but to use his skills for good towards conservation. Many have come to him for advice and have called him a living computer, constantly learning, adapting and solving problems many find challenging.
</p>
</div>
</section>
<div class="pimg2">
<video autoplay muted loop>
<source src="pimg2.mp4" type="video/mp4">
</video>
<div class="ptext">
<span class="border trans">
Did you know that in 2020 Ocean Cleanup broke world record using technolgy to collect <strong><i>103 tons of plastic</strong></i>!
</span>
</div>
</div>
<section class="section section-dark">
<h2>Design Tools</h2>
<p>
Pen & Paper, Sketch pad, Webflow, Apple Mac, photography/videography camera, dive gear, Microsoft Office, Adobe Photoshop, Adobe Lightroom, & Adobe Animate.
</p>
</section>
<div class="pimg3">
<video autoplay muted loop>
<source src="pimg3.mp4" type="video/mp4">
</video>
<div class="ptext">
<span class="border trans">
Did you know that because of technology, scientist are using biorock which gives coral reefs a 1600% to 5000% higher chance of survival?
</span>
</div>
</div>
<section class="section section-dark">
<h2>Developer Tools</h2>
<p>
Github, HTML, CSS, PHP, Python, JS, Sublime Text Editor, Visual Code Text Editor, & Bootstrap.
</p>
</section>
<div class="pimg4">
<div class="ptext4">
<span class="border trans">
<ul>
<li>Would you like to know more about becoming a true conservationist?</li>
<br>
<li>(website coming soon)</li>
<br>
<li><strong><i>ACurry.Business#gmail.com</i></strong></li>
</span>
<a href="http://open.spotify.com/user/q77rp6h9ot83qjk8r9xxg63hn" target="_blank">
<img src="spotify.png" class="spotify">
</a>
<a href="https://www.linkedin.com/in/arthurcurry/" target="_blank">
<img src="linkedin.png" class="linkedin">
</a>
<a href="https://www.instagram.com/oceanic_conservationist/" target="_blank">
<img src="instagram.png" class="instagram">
</a>
</div>
</div>
</body>
</html>
There are just way too many things wrong with your website. Furthermore, I am honestly unable to understand your concern here.
If the title is the only concern, it is because you have not made your website responsive.
Use this as a reference.
#media(max-width:568px) {
.pimg1,
.pimg2,
.pimg3 {
background-attachment: scroll;
}
}
That is the only part that aims at responsiveness. You have to aim at every breakpoint possible. It looks different in different browsers and mobile because your website aims at 568px and below. That's close to a phone resolution than a PC resolution (Consider 4k screens as well). Make different breakpoints, use dev tools on chrome and reduce the screen size to see what's out of place, create a media query for that and try fixing it.
Also, try learning flexbox or grid. Does wonders and shouldn't take more than a day.
It takes time to get better and be glad that you started. Nobody builds a perfect website the first time.
Bonus:
.ptext4 {
top: 450%;
Delete "top" to view your footer.

How do I put text next to an image?

So I've read about a hundred questions and answers on this and clearly I'm doing something wrong here... (Ignore the seriousness of the text, I'm making a loan calculator as an ability test)
I want my image, next to my text on the same line, this is how it currently looks
Here is my relevant code
.topContainer {
background-color: #0f3759;
overflow: hidden;
padding: 20px;
width: 100%;
}
.topContainer p {
width: 60%;
float: left;
}
.topContainer img {
margin-left: 35%;
width: 40%;
}
<div class="topContainer">
<h2 id="headline">Personal Loans</h2>
<p id="headlineText">18.9% APR Representative on loans between £100,000 to £1,000,000 over 1 to 10 years.</p>
<p id="headlineDesc">Other loan amounts and terms are available, at different rates. Our loans start at £100,000.
<br><br>Thinking about a big bet or buying an asset? Need some extra cash to pay off some debts? A Nub Bank personal loan can help make it happen.
<br><br>Lending and rate are subject to our assessment of your circumstances. Available to UK residents aged 18 and over.</p>
<img id="cash" src="https://cdn1.iconfinder.com/data/icons/flat-world-currency-1/432/Flat_Currency_Pound-512.png" width="300" height="300">
</div>
As PaulieD suggested, removing your image margin puts it all on one line.
Your problem is that you are asking for the text to take up 60% of the width, the image to take up 40% of the width, and the image margin to take up a further 35% of the width. Obviously this takes up more than 100% of the page so it shunts the extra stuff below. Here's what it looks like without the margin:
.topContainer {
background-color: #0f3759;
overflow: hidden;
padding: 20px;
width: 100%;
}
.topContainer p {
width: 60%;
float: left;
}
.topContainer img {
width: 40%;
}
<div class="topContainer">
<h2 id="headline">Personal Loans</h2>
<p id="headlineText">18.9% APR Representative on loans between £100,000 to £1,000,000 over 1 to 10 years.</p>
<p id="headlineDesc">Other loan amounts and terms are available, at different rates. Our loans start at £100,000.
<br><br>Thinking about a big bet or buying an asset? Need some extra cash to pay off some debts? A Nub Bank personal loan can help make it happen.
<br><br>Lending and rate are subject to our assessment of your circumstances. Available to UK residents aged 18 and over.</p>
<img id="cash" src="https://cdn1.iconfinder.com/data/icons/flat-world-currency-1/432/Flat_Currency_Pound-512.png" width="300" height="300">
</div>
Just as a "best practices with modern HTML/CSS" thing, an easier way to add gaps between elements is to use something like flex or grid. Below is an example using grid, with a gap in between the elements:
.topContainer {
background-color: #0f3759;
overflow: hidden;
padding: 20px;
width: 100%;
}
.mainBody {
display: grid;
grid-template-columns: 3fr 2fr;
grid-column-gap: 50px;
}
<div class="topContainer">
<h2 id="headline">Personal Loans</h2>
<div class="mainBody">
<div class="text">
<p id="headlineText">18.9% APR Representative on loans between £100,000 to £1,000,000 over 1 to 10 years.</p>
<p id="headlineDesc">Other loan amounts and terms are available, at different rates. Our loans start at £100,000.
<br><br>Thinking about a big bet or buying an asset? Need some extra cash to pay off some debts? A Nub Bank personal loan can help make it happen.
<br><br>Lending and rate are subject to our assessment of your circumstances. Available to UK residents aged 18 and over.</p>
</div>
<img id="cash" src="https://cdn1.iconfinder.com/data/icons/flat-world-currency-1/432/Flat_Currency_Pound-512.png" width="300" height="300">
</div>
Use bootstrap its very easy and save you from lot of css coding...
...but if you dont want to use I would say use flex box for it. :)
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
You can see my solution for you here
.topContainer { display: flex; }
try this:
.topContainer {
background-color: #0f3759;
overflow: hidden;
padding: 20px;
width: 100%;
}
.contain{
display: flex;
}
.topContainer .text_block {
float: left;
}
.topContainer img {
width: 40%;
height: auto;
float: right;
}
<div class="topContainer">
<h2 id="headline">Personal Loans</h2>
<div class="contain">
<div class="text_block">
<p id="headlineText">18.9% APR Representative on loans between £100,000 to £1,000,000 over 1 to 10 years.</p>
<p id="headlineDesc">Other loan amounts and terms are available, at different rates. Our loans start at £100,000.
<br><br>Thinking about a big bet or buying an asset? Need some extra cash to pay off some debts? A Nub Bank personal loan can help make it happen.
<br><br>Lending and rate are subject to our assessment of your circumstances. Available to UK residents aged 18 and over.</p>
</div>
<img id="cash" src="https://cdn1.iconfinder.com/data/icons/flat-world-currency-1/432/Flat_Currency_Pound-512.png" width="300" height="300">
</div>
</div>
I've put the two paragraph tags in a container div, then utilised flex box to put both the paragraph container and the image container on the same line - you can then set any padding or margin on their. As you've set the image width to a percentage, I've also set it's height to auto to allow it to keep it's ratio.

Why won't div's height expand to its child elements?

I'm still in the process of mastering css.
So I've made my portfolio website from scratch. as you scroll you'll see the main content is made up of a two column layout. My columns are fixed, wrapped in a relative div that takes up 100% width. the two fixed divs inside take up 50% width. Then I put content inside of the fixed divs -- like my portfolio.
But sometimes the fixed divs height don't expand to the height of the content within it. Especially when you resize. Why?
Here's a link to my website so you can see what I mean.
http://parkhargravedesigns.com/
if ($(window).width() > 768) {
$('.f, .fixedContainer').css('height', $('.text').height());
$(window).resize(function() {
$('.f, .fixedContainer').css('height', $('.text').height());
});
$('.f2,.fixedContainer2').css('height', $('.text2').height());
$(window).resize(function() {
$('.f2,.fixedContainer2').css('height', $('.text2').height());
});
$('.f3, .fixedContainer3').css('height', $('.text3').height());
$(window).resize(function() {
$('.f3, .fixedContainer3').css('height', $('.text3').height());
});
}
.fixedContainer,
.fixedContainer2,
.fixedContainer3 {
position: relative!important;
width: 100%!important;
}
.headerEle2 {
display: block!important;
}
.f,
.f2,
.f3 {
background-color: #293553;
background-size: cover!important;
width: 50%!important;
position: absolute!important;
top: 0;
left: 0;
color: black;
font-size: 70px;
}
.f2 {
background-color: #e7384c!important;
}
.text,
.text2,
.text3 {
background-color: white!important;
background-size: cover!important;
color: black;
position: absolute!important;
right: 0!important;
top: 0!important;
width: 50%!important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fixedContainer">
<div class="f">
<div id="aboutStuff">
<p class="fTitle">
About
</p>
<div class="headerEle2 NavDiv"></div>
</div>
</div>
<div id="profilePic">
<img src="album/profilePic2.png" alt="oops">
</div>
<div class="text">
<h1>I'M A WEB & GRAPHIC DESIGNER FROM B.C, CANADA.</h1>
<p>
A strong interest in art and design was my gateway to the creative industry, which led to taking my first steps in the digital world. During my time at North Island College I fell inlove with web design because it allowed me to express my creativity while
developing the skills necessary to create functionable websites.
</p>
<h1>SERVICES:</h1>
<p>
<b>Website Design and Development Logo Design</b>
</p>
<h1>QUALIFICATIONS:</h1>
<p>
<b>HTML
CSS
JavaScript
JQuery
Illustrator
Photoshop
</b>
</p>
<h1>EDUCATION:</h1>
<p>
<b>Program:</b> Web Design & Interactive Media Certificate
<b>Where:</b> North Island College, Comox Valley, BC In this program I gained skills in HTML,<br> CSS, Javascript, PHP and Adobe CC.
</p>
<h1>DESIGN PROCESS</h1>
<p>
A user-centered mindset and sensitivity for design are <br> key concepts I carry throughout the design process.<br><br> This rough framework outlines my process of<br> developing digital experiences: 1. RESEARCH and gather the present state 2. STRUCTURE
setup and content of the project 3. CONCEPT AND STRATEGY <br> 4. CREATE, evaluate and iterate deliverables like -Site maps -User flow -Sketches and Infographics -Wireframes
</p>
<!--
<img src = "album/homeFixed.png" alt = "oops" id = "text1Logo">
-->
</div>
</div>