column image behave as background image - html

I have two columns using flexbox but does not have to use flexbox. just using it at the moment but am open to other options. The left side is content with a width of 450px and the right column I have an image that needs to behave as a background image but not use css background property. Is there a way to set the image size / image column and have it overflow out of containers and not push the left column content?
setting container widths and using relative positioning but not scaling or behaving as I would like
.row--flex {
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
margin: 0;
}
.content-col--450 {
max-width: 450px;
}
.content-col {
margin-bottom: auto;
margin-top: 97px;
padding-bottom: 20px;
}
.image-col {
padding-left: 10px;
}
}
.image {
width: 100%;
height: auto;
}
<div class="container container--outer">
<div class="row--flex">
<!--content-->
<div class="content-col content-col--450">
<div class="title-row">
<h2>
testing h2
</h2>
</div>
<div class="content-row">
<p class="p-margin-bottom">
testing P
</p>
<p class="lead">
download test
</p>
<button class="button--arrow">
<span class="button--text">download now</span>
</button>
</div>
</div>
<!--end content-->
<!--image-->
<div class="image-col">
<img src="/img/right-image.png" alt="right column image" class="image-test">
</div>
<!--end image-->
</div>
column 450 stay in place and image overflow out of containers and behave as BG image

You need something like this?
.row--flex {
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
margin: 0;
}
.content-col--450 {
/* max-width: 450px; */
flex-basis: 450px;
}
.content-col {
margin-bottom: auto;
margin-top: 97px;
padding-bottom: 20px;
}
.image-col {
position: relative;
flex-basis: 450px;
align-self: stretch;
padding-left: 10px;
}
.image-test {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
object-fit: cover;
}
.image {
width: 100%;
height: auto;
}
<div class="container container--outer">
<div class="row--flex">
<div class="content-col content-col--450">
<div class="title-row">
<h2>
testing h2
</h2>
</div>
<div class="content-row">
<p class="p-margin-bottom">
testing P
</p>
<p class="lead">
download test
</p>
<button class="button--arrow">
<span class="button--text">download now</span>
</button>
</div>
</div>
<div class="image-col">
<img class="image-test" src="https://picsum.photos/536/354" alt="right column image">
</div>
</div>
</div>

Related

Problem laying out items in an image gallery

I am having trouble laying out my items in a gallery. I would like to be able to display an image in a horizontal or vertical format and have it fit within a fixed 300px x 300px box and align to the bottom of the box. I would like the "attribution" to line up with the right edge of the image. Here is a picture of the desired layout.
Picture of desired layout
This is the html:
.gallery {
display:flex;
gap: 10px;
}
.gallery_item_square {
height: 450px;
width: 300px;
background: brown;
}
.gallery_square {
height: 300px;
display: flex;
background: green;
}
.gallery_description {
height:auto;
width:100%;
}
.image_attribution {
display:flex;
flex-direction:column;
align-items:flex-end;
}
.image_square {
width: 100%;
height: 100%;
background: black;
display:flex;
flex-direction:column;
align-items:flex-end;
}
.gallery_attribution {
width: 100%;
background: orange;
display: flex;
}
.image {
height:100%;
background: green;
width:
}
.image_contain {
width: 100%;
height: 100%;
object-fit:contain;
object-position: bottom;
}
.attribution {
float:right;
}
<div class="gallery">
<div class="gallery_item_square">
<div class="gallery_square">
<div class="image_attribution">
<div class="image_square">
<div class="image">
<img class="image_contain" src="https://acrossky.github.io/Images/3W6A8814.jpg">
<span class="attribution"> ARC/Qedema</span>
</div>
</div>
</div>
</div>
<div class="gallery_description">
<p>This is a description</p>
</div>
</div>
<div class="gallery_item_square">
<div class="gallery_square">
<div class="image_attribution">
<div class="image_square">
<div class="image">
<img class="image_contain" src="https://acrossky.github.io/Images/3W6A8817.jpg">
<span class="attribution"> ARC/Qedema</span>
</div>
</div>
</div>
</div>
<div class="gallery_description">
<p>This is a description</p>
</div>
</div>
</div>
I am unable to make the image fit within the box. Ive tried use "object-fit:contain" but to no avail. I would be grateful for any help you can offer.
Update: the code is almost working. The last item is to make the attribution align with edge of the image. align attribution to edge of image Here is the latest version of the code in Codepen.
https://codepen.io/acrossky/pen/KKoNdPX
Maybe something like this:
.gallery {
display: flex;
gap: 10px;
}
.gallery_item_square {
height: 450px;
width: 300px;
background: brown;
}
.gallery_square {
height: 300px;
width: 100%;
display: flex;
justify-content: center;
background: green;
}
.gallery_description {
width: 100%;
height: auto;
}
.image_attribution {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.image_square {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.gallery_attribution {
width: 100%;
background: orange;
display: flex;
justify-content: center;
}
.image {
height: 100%;
width: 100%;
}
.image_contain {
width: 100%;
height: 100%;
object-fit: contain;
object-position: bottom;
}
.attribution {
display: block;
}
<div class="gallery">
<div class="gallery_item_square">
<div class="gallery_square">
<div class="image_attribution">
<div class="image_square">
<div class="image">
<img class="image_contain" src="https://acrossky.github.io/Images/3W6A8814.jpg">
<span class="attribution"> ARC/Qedema</span>
</div>
</div>
</div>
</div>
<div class="gallery_description">
<p>This is a description</p>
</div>
</div>
<div class="gallery_item_square">
<div class="gallery_square">
<div class="image_attribution">
<div class="image_square">
<div class="image">
<img class="image_contain" src="https://acrossky.github.io/Images/3W6A8817.jpg">
<span class="attribution"> ARC/Qedema</span>
</div>
</div>
</div>
</div>
<div class="gallery_description">
<p>This is a description</p>
</div>
</div>
</div>

Pinning icons to top of the vertical flexbox bar

I have 3 vertical flexbox bars with different height and I'd like to place 3 different icons on the top of 3 vertical bars.
I tried by using margin and padding to fix the icons at the top of the flexbox but when i switch the window to responsive mode then again icons moves to different places.
Here is an image of how i wanted:
Here's an image of how i am getting like:
My HTML Code:
<div>
<div className="prize">
<div class="prizeimage2">
<img src={prizeTwo} alt="2ndprizeicon"/>
</div>
<div class="prizeimage1">
<img src={prizeOne} alt="1stprizeicon"/>
</div>
<div class="prizeimage3">
<img src={prizeThree} alt="3rdprizeicon"/>
</div>
</div>
<div className="container">
<div class="item item1">
<p className="hourstext">28<br></br> hrs</p>
</div>
<div class="item item2">
<p className="hourstext">25<br></br> hrs</p>
</div>
<div class="item item3">
<p className="hourstext">30<br></br> hrs</p>
</div>
</div>
</div>
CSS:
.container {
position: absolute;
width: 100%;
height: 70%;
left: 0px;
top: 0px;
display: flex;
justify-content: center;
align-items: flex-end;
background: #162983;
}
.prize{
position: relative;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
z-index: 1;
}
.item {
width: 75px;
background: #8C9CE7;
}
.item1 {
height: 35%;
margin-left: 2px;
}
.item2 {
height: 45%;
margin-left: 9px;
}
.item3 {
height: 20%;
margin-left: 10px;
}
.prizeimage1 {
padding-bottom: 5%;
}
.prizeimage2 {
padding-top: 45px;
}
.prizeimage3 {
padding-top: 190px;
}

Flexbox Wrap Not Working On 4 Of My Images

Hello Im not sure why but for some reason flexbox is not working.
I have 4 images on one section. I added flexbox wrap on the container and I also assigned flex 1
on the children images but for some reason flexbox is not working.
If anyone could help and let me know what I am doing wrong I would really appreciate it.
https://codepen.io/rubenjr005/pen/rNexOZp?editors=0100
HTML CODE
<div id="capabilities" class="bg-dark-02 py-2 angle-top-bottom-right">
<div class="capabilities-title">
<h4 class="section-title text-center">CAPABILITIES</h4>
<h3 class="lead text-center">I DO THINGS LIKE</h3>
</div>
<div class="capabilities-container">
<div class="category">
<div class="content">
<img src="img/graphic-design-icon_03.png" alt="Graphic Design" />
<div class="text-animation">
<h3 class="text-center">GRAPHIC DESIGN</h3>
</div>
</div>
</div>
<div class="category">
<div class="content">
<img src="img/Web-Design-icon_01.jpg" alt="Web Design" />
<div class="text-animation">
<h3 class="text-center">Web Design</h3>
</div>
</div>
</div>
<div class="category">
<div class="content">
<img src="img/web-development-01.png" alt="web Development" />
<div class="text-animation">
<h3 class="text-center">Web Development</h3>
</div>
</div>
</div>
<div class="category category4">
<div class="content">
<img src="img/email-development.png" alt="Email Development" />
<div class="text-animation">
<h3 class="text-center">Email Development</h3>
</div>
</div>
</div>
</div>
</div>
SCSS
#capabilities {
height: 100%;
margin-bottom: 4.5rem;
.capabilities-container {
display: flex;
flex-wrap: wrap;
// min-width: 20%;
.category {
display: flex;
// flex-direction: column;
flex: 1;
padding: 1rem;
align-items: center;
justify-content: center;
min-width: 10rem;
// width: 10rem;
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
img {
position: absolute;
top: 30%;
height: 12rem;
width: auto;
display: block;
// margin: auto;
margin-bottom: 4rem;
opacity: 0.4;
transition: 0.75s;
// padding-bottom: 4rem;
}
.text-animation {
// position: absolute;
text-align: center;
padding-top: 15rem;
transition-duration: 0.75s;
text-align: center;
left: 0;
right: 0;
// background: red;
// margin: auto;
h3 {
color: white;
text-transform: uppercase;
// margin: auto;
}
}
}
}
.category:hover .content img {
opacity: 1;
margin-bottom: 1rem;
// padding-bottom: 0rem;
// padding-bottom: 0rem;
}
.category:hover .content .text-animation {
// opacity: 1.0;
padding-top: 10rem;
}
}
}
You have to get rid of absolute positioning on your img and you'll have to use media queries.
Starting from there, you'll see the flex-wrap: wrap working.
Here is a fork : https://codepen.io/hisato/pen/vYGLLNY?editors=0100
Also, if I may add, as a general advice avoid to transition margin/padding/top/left etc. You should always look for a way to transition the transform property, it will have the best performance.

position text on image correctly {CSS HTML}

[How to position text on the image correctly? i got three blocks of text which i want to position them on the same line on the image but i struggle with it :(
#banner {
justify-content: center;
height: 600px;
margin-top: 100px;
margin-left: 10%; }
.banner-text {
color: white;
justify-content: center;
justify-content: space-around;
text-align: center;
display: inline-block;
position: absolute;
flex-direction: column; }
/*DownTown*/
.flex-text {
background-color: grey;
text-align: center;
}
html
<div id="banner"><img src="2525.jpeg">
<div class="banner-text">
<div class="flex-text text1">
<h1><b>DownTown</b> 384 West 4th St Suite 108</h1>
<div class="flex-text text2">
<h1><b>East Bayside</b> 3433 Phisherman Avenue </h1>
<div class="flex-text text3">
<h1><b>Oakdale</b> 515 Crecent avenue Second Floor </h1>
</div>
</div>
</div>
</div>
</div>
here is how it should look
]2
and that's how i did it -_-
Your html markup is not correct and instead of adding image as an img element in the #banner, add the image as a background image using css. That way, you don't need position absolute to place text over the image. After that, use flexbox for aligning the elements.
#banner {
background-image: url(https://picsum.photos/500);
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.banner-text {
color: white;
justify-content: space-around;
display: flex;
width: 100%;
flex-wrap: wrap;
}
.flex-text {
background-color: #222;
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-between;
height: 180px;
padding: 20px;
width: 200px;
margin: 5px;
}
h1 {
margin: 0;
}
<div id="banner">
<div class="banner-text">
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
</div>
</div>
Your markup is not right. So I changed it a bit. And I also changed the css accordingly and use flex for aliigning items. And instead of using img in html I use background property.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1200px;
height: 100vh;
margin: auto;
overflow: hidden;
padding: 1rem;
background: #333;
}
#banner {
margin-top: 100px;
}
.banner-text {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
color: white;
}
/*DownTown*/
.flex-text {
background-color: rgba(0, 0, 0, 0.384);
line-height: 4rem;
padding: 4rem;
margin: 0rem 2rem;
text-align: center;
}
<div class="container">
<div id="banner">
<!-- <img src="2525.jpeg" /> -->
<div class="banner-text">
<div class="flex-text text1">
<h1>DownTown</h1>
<p>384 West 4th St</p>
<p>Suite 108</p>
</div>
<div class="flex-text text2">
<h1>East Bayside</h1>
<p>3433 Phisherman Avenue</p>
<p>(Norway Corner)</p>
</div>
<div class="flex-text text3">
<h1>Oakdale</h1>
<p>
515 Crecent avenue
</p>
<p>
Second Floor
</p>
</div>
</div>
</div>
</div>
The issue you have is the root diff i.e #banner has two child. The properties on #banner doesn't indicate in any way that the two items should overlap. You are trying to achieve that through position:absolute. Which is also an approach. But here's how you can achieve what you want in two ways:
Put that image as the background property for #banner and provide the flexbox properties to banner.
body {
margin: 0;
max-width: 100%;
}
#banner {
position: relative;
height: 600px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#banner img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 1;
}
.banner-text {
position: relative;
width: 100%;
z-index: 2;
display: flex;
justify-content: space-around;
}
.flex-text {
background: #efefef;
}
h1 {
font-size: 17px;
}
<div id="banner">
<img src="https://cdn.slashgear.com/wp-content/uploads/2019/07/coffee_main_envat-1280x720.jpg">
<div class="banner-text">
<div class="flex-text text1">
<h1><b>DownTown</b><br/> 384 West 4th St Suite 108</h1>
</div>
<div class="flex-text text2">
<h1><b>East Bayside</b><br/> 3433 Phisherman Avenue </h1>
</div>
<div class="flex-text text3">
<h1><b>Oakdale</b><br/> 515 Crecent avenue Second Floor </h1>
</div>
</div>
</div>
Position your banner div relative. Then position your image as absolute so that it occupies whole width and banner-text should have relative positioning. One other thing you need to do if the text doesn't come to center is provide 100% width to the banner-text.
Hope this solves the problem

My Div does not React to Position: Absolute With The Container Div set to Position: Relative

This should be fairly simple, however I am stumped as to why it is not working. The div (logo-and-text) inside the container (logo-wrapper) does not want to work with position absolute and the parent as position relative. If I do the individual image inside the div or the text it works.
I've tried setting the height of the container, setting margins to zero, checked in chrome dev tools.
<section id="contact-me-section">
<div id="contact-me-section-wrapper">
<div id="have-a-question-wrapper">
<h2 class="contact-h2">HAVE A QUESTION?</h2>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/location.png" alt="">
<p class="contact-p">Dayton, Ohio</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/phone.png" alt="">
<p class="contact-p">( 937 ) 336-9359</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/email.png" alt="">
<p class="contact-p">contact#ryanjthacker.com</p>
</div>
</div>
<div id="logo-wrapper">
<div id="logo-and-text">
<img src="images/logo.png" alt="">
<p>Copyright © 2019 Ryan Thacker - All rights reserved</p>
</div>
</div>
<div id="connect-with-me-wrapper">
<h2 class="contact-h2">CONNECT WITH ME</h2>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/facebook_white.png" alt="">
<p class="contact-p">Facebook</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/linkedin_white.png" alt="">
<p class="contact-p">LinkedIn</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/github_white.png" alt="">
<p class="contact-p">GitHub</p>
</div>
</div>
</div>
</section>
#contact-me-section {
color: white;
background-color: black;
height: auto;
width:100%;
}
#contact-me-section-wrapper {
display: flex;
text-align: center;
justify-content: center;
}
#have-a-question-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 100px;
}
#logo-wrapper {
margin-left: 150px;
margin-right: 150px;
position: relative;
height: 100%;
}
#logo-and-text {
position: absolute;
bottom: 0;
}
#logo-wrapper img {
width: 116px;
margin: 10px;
}
#connect-with-me-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 100px;
}
.contact-h2 {
font-size: 17px;
margin: 20px;
padding-top: 60px;
padding-bottom: 30px;
text-align: left;
}
.contact-p {
color: #989898;
margin-top:auto;
margin-bottom:auto;
font-size: 15px;
}
.contact-img {
width: 60px;
margin: 20px;
}
.connect-with-me-image-wrapper {
display: flex;
flex-direction: row;
}
I believe I have solved it, its due to using flex box. The solution is a much easier and flexible way to do it.
Instead I just used align-self: flex-end; to the container.