I have a container div that is a background that changes size dynamically with the window. Inside that container I have an image div that I want to change size with the background container. I can't seem to get it to resize dynamically even using percentage heights and widths. Can anyone guide me in the correct direction?
#import url("https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600,700,800");
* {
box-sizing: border-box;
}
body {
background-color: #af39fe;
background-image: linear-gradient(147deg, #af39fe 0%, #4c38fd 74%);
min-height: 100vh;
font-family: "Fira Sans", sans-serif;
display: flex;
}
.info-container {
width: 95%;
position: relative;
max-width: 800px;
margin: auto;
background: #fff;
box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2);
padding: 25px;
border-radius: 10px;
height: auto;
}
.info-container__img {
width: 400px;
flex-shrink: 0;
height: 400px;
background-image: linear-gradient(147deg, #af39fe 0%, #4c38fd 74%);
box-shadow: 4px 13px 30px 1px rgba(252, 56, 56, 0.2);
border-radius: 10px;
transform: translateX(-80px);
overflow: hidden;
}
.info-container__img img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
opacity: 100;
border-radius: 10px;
}
.info-container__content {
padding-right: 25px;
}
.info-container__content>* {
opacity: 100;
}
.info-container__title {
font-size: 24px;
font-weight: 700;
color: #0d0925;
margin-bottom: 20px;
}
.info-container__text {
color: #4e4a67;
margin-bottom: 30px;
line-height: 1.5em;
}
.info-container__button {
display: inline-flex;
background-image: linear-gradient(147deg, #5b0a6b 0%, #16034b 74%);
padding: 15px 35px;
border-radius: 50px;
color: #fff;
box-shadow: 0px 14px 80px rgba(0, 0, 0, 0.4);
text-decoration: none;
font-weight: 500;
justify-content: center;
text-align: center;
letter-spacing: 1px;
}
<div class="info-container">
<div class="info-container__img">
<img src="https://www.dmarge.com/wp-content/uploads/2021/01/dwayne-the-rock-.jpg">
</div>
<div class="info-container__content">
<div class="info-container__title">About Me</div>
<div class="info-container__text">This is fake info about a persons life.</div>
READ MORE
</div>
</div>
You set .info-container__img's width using pixels. Change that to percentages and it would act as you want. I set max-width: 400px and change width: 50% in respect to container's style.
#import url("https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600,700,800");
* {
box-sizing: border-box;
}
body {
background-color: #af39fe;
background-image: linear-gradient(147deg, #af39fe 0%, #4c38fd 74%);
min-height: 100vh;
font-family: "Fira Sans", sans-serif;
display: flex;
}
.info-container {
width: 95%;
position: relative;
max-width: 800px;
margin: auto;
background: #fff;
box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2);
padding: 25px;
border-radius: 10px;
height: auto;
}
.info-container__img {
width: 50%;
max-width: 400px;
flex-shrink: 0;
height: auto;
background-image: linear-gradient(147deg, #af39fe 0%, #4c38fd 74%);
box-shadow: 4px 13px 30px 1px rgba(252, 56, 56, 0.2);
border-radius: 10px;
transform: translateX(-80px);
overflow: hidden;
}
.info-container__img img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
opacity: 100;
border-radius: 10px;
}
.info-container__content {
padding-right: 25px;
}
.info-container__content>* {
opacity: 100;
}
.info-container__title {
font-size: 24px;
font-weight: 700;
color: #0d0925;
margin-bottom: 20px;
}
.info-container__text {
color: #4e4a67;
margin-bottom: 30px;
line-height: 1.5em;
}
.info-container__button {
display: inline-flex;
background-image: linear-gradient(147deg, #5b0a6b 0%, #16034b 74%);
padding: 15px 35px;
border-radius: 50px;
color: #fff;
box-shadow: 0px 14px 80px rgba(0, 0, 0, 0.4);
text-decoration: none;
font-weight: 500;
justify-content: center;
text-align: center;
letter-spacing: 1px;
}
<div class="info-container">
<div class="info-container__img">
<img src="https://www.dmarge.com/wp-content/uploads/2021/01/dwayne-the-rock-.jpg">
</div>
<div class="info-container__content">
<div class="info-container__title">About Me</div>
<div class="info-container__text">This is fake info about a persons life.</div>
READ MORE
</div>
</div>
So I decided to do my portfolio website on my own, which turned out to work pretty ok so far. The only problem is that I can't seem to make it display properly on mobile view. That's even though I've made all the pertinent changes on the css with "#media screen"
Can somebody take a look and tell me why it's doing what it's doing?
To see the problem, go to https://er-sc.com/HTML/image_making.html
on mobile view
In the proper way the image shouldn't cover the "about" button.
Also if you notice anything I could correct to make the website better, let me know.
Looking forward to the community's feedback and suggestions.
Best,
Ellie
Here's my HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ERSC Image Making</title>
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
<link href="../CSS/styles.css" rel="stylesheet" type="text/css">
</head>
<body id="bigwrapper">
<div class="topleft">
<a class="logoButton" href="https://www.er-sc.com/">E</a>
</div>
<div class="bottomleft">
<a class="logoButton" href="https://www.er-sc.com/">S</a>
</div>
<div class="topright">
<a class="logoButton" href="https://www.er-sc.com/">R</a>
</div>
<div class="bottomright">
<a class="logoButton" href="https://www.er-sc.com/">C</a>
</div>
<div class="bottomcenterLinks">
ABOUT
</div>
<div class="projectWrapper">
<div class="oneProject">
<div class="text">Happy Dancer, 2022</div>
<img src="/images/image-making/22-happy-dancer_k.jpg" alt="figure jumping">
</div>
<div class="oneProject">
<div class="text">Relief, 2022</div>
<img src="/images/image-making/22-0127_1__0020_Ebene-21-Wiederhergestellt_k.jpg" alt="3D extrusion of a scribble with plaster texture">
</div>
<div class="oneProject">
<div class="text">Didi, 2021</div>
<img src="/images/image-making/21-1210didi_k.jpg">
</div>
<div class="oneProject">
<div class="text">Dancing Flowers pt I, 2021</div>
<img src="/images/image-making/21-IG1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Dancing Flowers pt II, 2021</div>
<img src="/images/image-making/21-IG2_k.jpg">
</div>
<div class="oneProject">
<div class="text">Sad Clown, 2021</div>
<img src="/images/image-making/21-200126_3D_1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Alpine Anime (fictitious festival poster for Livia Rita), 2020</div>
<img src="/images/image-making/20-AlpineAnime_k.jpg">
</div>
<div class="oneProject">
<div class="text">Europa Endlos, 2019</div>
<img src="/images/image-making/19-europaendlos-scan_k.jpg">
</div>
<div class="oneProject">
<div class="text">Ascension, 2018</div>
<img src="/images/image-making/18-plakat_klein_ersc_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 1/4, 2018</div>
<img src="/images/image-making/18-1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 2/4, 2018</div>
<img src="/images/image-making/18-7_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 3/4, 2018</div>
<img src="/images/image-making/18-9_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 4/4, 2018</div>
<img src="/images/image-making/18-10_k.jpg">
</div>
</div>
</body>
</html>
And here's my CSS
html,
#index {
height: 100%;
width: 100%;
background: radial-gradient(circle, hsla(295, 79%, 24%, 1) 0%, hsla(71, 66%, 78%, 1) 40%, hsla(318, 76%, 81%, 1) 74%, hsla(202, 27%, 45%, 1) 100%););
color: #551A8B;
font-family: sans-serif;
font-size: 1em;
background-attachment: fixed;
display: flex;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
#bigwrapper{
height: 100%;
width: 100%;
background: radial-gradient(circle, hsla(295, 79%, 24%, 1) 0%, hsla(71, 66%, 78%, 1) 40%, hsla(318, 76%, 81%, 1) 74%, hsla(202, 27%, 45%, 1) 100%););
color: #551A8B;
font-family: sans-serif;
font-size: 1em;
background-attachment: fixed;
display: flex;
display: -webkit-flex;
display: flex;
-webkit-align-items: top !important;
align-items: top !important;
-webkit-justify-content: center;
justify-content: center;
}
#font-face {
font-family: 'FT88-Italic';
font-style: normal;
font-weight: 400;
src: url('/fonts/FT88-Italic') format('woff2');
}
p {
font-family: 'FT88-Italic', sans-serif;
}
h1 {
font-family: 'FT88-Italic', sans-serif;
font-size: 2vw;
font-weight: normal;
}
.socials{
font-size: 2vw;
}
a {
text-decoration: none;
color: #551A8B;
font-family: sans-serif;
}
mark {
background-color: rgba(85, 26, 139, 1);
color: white;
border-radius: 0.3em;
}
#wrapper {
height: 80%;
width: 80%;
padding: 0em;
}
.extraBG {
z-index: 1000;
height: 100vh;
width: 50vw;
position: fixed;
background-color: red;
right: 0%;
top:0%
background-repeat: repeat;
background-position: top right;
background-attachment: fixed;
}
.topleft{
position: fixed;
top: 3%;
left: 3%;
z-index: 100;
}
.bottomleft{
position: fixed;
bottom: 3%;
left: 3%;
z-index: 100;
}
.topright{
position: fixed;
top: 3%;
right: 3%;
z-index: 100;
}
.bottomright{
position: fixed;
bottom: 3%;
right: 3%;
z-index: 100;
}
.bottomcenterLinks{
position: fixed;
bottom: 5%;
text-align: center;
text-decoration: none;
vertical-align: middle;
display: table-cell;
font-family: "FT88-Italic", sans-serif;
font-size: 3vh;
color: floralwhite;
}
.bottomcenterLinks a {
color: floralwhite;
text-shadow: 0px 0px 0.25em #551A8B;
}
.bottomcenterLinks a:hover {
color: floralwhite;
text-shadow: 0px 0px 0.15em floralwhite;
transition: 0.6s ease;
}
.bottomcenterLinks a:active {
color: floralwhite;
text-shadow: 0px 0px 0.15em floralwhite;
transition: 0.6s ease;
}
.bottomSmall{
text-align: center;
font-size: 0.8em;
align-self: flex-end;
}
.logoButton {
background-color: floralwhite;
font-family: sans-serif;
width: 8vh;
height: 8vh;
text-align: center;
vertical-align: middle;
text-decoration: none;
display: table-cell;
font-size: 3vh;
cursor: pointer;
border-radius: 100%;
z-index: 999;
position: relative;
box-shadow: inset 6px -6px 8px 1px rgba(224, 211, 185, 0.8), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
text-transform: uppercase;
z-index: 999;
filter: blur(0.05em);
-webkit-filter: blur(0.05em);
}
.logoButton:hover, .logoButton:active{
box-shadow: inset 6px -6px 0.8em 1px rgba(255, 255, 255, 0.8), inset -16px 18px 0.8em 0.05em rgba(224, 211, 185, 0.8);
filter: blur(0em);
-webkit-filter: blur(0em);
}
.centeredBox{
margin: auto;
border-radius: 5em;
background: floralwhite;
text-align: center;
font-size: 1.2em;
padding: 0.6em;
vertical-align: middle;
margin: auto;
height: 90%;
display: flex;
flex-wrap : nowrap;
flex-direction: column;
justify-content: center;
align-items : stretch;
flex-direction: column;
align-content : space-between;
/* box-shadow: inset 6px -6px 0.5em 1px rgba(224, 211, 185, 0.5), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
*/
}
.centeredBox small{
text-align: center;
align-content : flex-end;
}
.part1, .part2, .part3, .part4, .part5{
border-radius: 100em;
background: floralwhite;
text-align: center;
box-shadow: inset 6px -6px 0.5em 1px rgba(224, 211, 185, 0.5), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
vertical-align: middle;
filter: blur(0.1em);
-webkit-filter: blur(0.1em);
}
.part1:hover, .part2:hover, .part3:hover, .part4:hover, .part5:hover, .part5:active {
box-shadow: inset -21px 26px 50px -51px #FFFAF0, inset 10px -13px 50px -31px #FFFAF0, inset 34px -36px 50px 35px rgba(255, 255, 255, 0.6), inset -31px 37px 50px 32px rgba(224, 211, 185, 0.25);
filter: blur(0em);
-webkit-filter: blur(0em);
}
/*
.centeredBox, .slideshowBox{
width:100%;
height: 100%;
float: left;
}
*/
.centeredBox p {
position: relative;
padding: 1em;
height:20px;
top: 5%;
transform: translateY(-50%);
text-align: center;
vertical-align: middle;
}
.part1 {
width:50%;
height: 30%;
float: left;
}
.part1 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part2 {
width:50%;
height: 30%;
float: left;
}
.part2 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part3 {
width:50%;
height: 30%;
float: left;
}
.part3 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part4 {
width:50%;
height: 30%;
float: left;
}
.part4 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part5 {
width:65%;
height: 33%;
margin: auto;
display:flex;
justify-content: center;
vertical-align: middle;
}
.part5 p {
position: relative;
text-align: center;
vertical-align: middle;
font-size: 6vw;
margin: auto;
/* transform: translateY(-50%); */
}
.selected{
color: #FFFAF0;
filter: blur(0.05em);
}
.slideshowBox{
border-radius: 4em;
background: floralwhite;
text-align: center;
font-size: 1.2em;
filter: drop-shadow(10px,10px,orange);
}
.slideshow-container{
height: 100%;
width: 90%;
padding-top: 0em;
padding-bottom: 0em;
border-radius: 4em;
margin: auto;
text-align: center;
vertical-align: middle;
}
.mySlides {
display: none;
text-align: center;
vertical-align: middle;
}
.projectWrapper {
z-index: 10;
display: inline-block;
text-align: center;
vertical-align: top;
margin-top: 5em;
/*overflow-y: scroll;
scroll-snap-type: y mandatory;*/
padding-bottom: 7.5em;
}
.oneProject {
padding-bottom: 7.5em;
/*scroll-snap-align: start;
scroll-snap-stop: always;*/
}
img {
/* vertical-align: middle; */
border-radius: 1em;
max-height: 75vh;
max-width: 75vw;
margin: auto;
display: block;
text-align: center;
}
.imgSmall {
max-height: 70vh;
}
/* Next & previous buttons */
.prev {
vertical-align: middle;
cursor: pointer;
position: absolute;
top: 10%;
left: 0em;
width: 40%;
padding-top: 17em;
padding-bottom: 17em;
color: rgba(0, 0, 0, 0);
font-size: 1.2em;
transition: 0.6s ease;
user-select: none;
}
/* Position the "next button" to the right */
.next {
vertical-align: middle;
cursor: pointer;
position: absolute;
top: 10%;
right: 0em;
width: 40%;
padding-top: 17em;
padding-bottom: 17em;
color: rgba(0, 0, 0, 0);
font-size: 1.2em;
transition: 0.6s ease;
user-select: none;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
color: rgba(0, 0, 0, 0);
}
/* Caption text */
.text {
font-size: 1.2em;
position: relative;
margin: auto;
display: block;
text-align: center;
padding-bottom: 0.5em;
font-family: sans-serif;
}
/* Fading animation */
.fade {
animation-name: fade;
animation-duration: 1.5s;
}
#keyframes fade {
from {opacity: .6}
to {opacity: 1}
}
#media screen and (max-width: 1200px) {
h1 {
font-size: 4vw;
}
.socials {
font-size: 3vw;
}
.bottomcenterLinks {
font-size: 3vh;
}
.selected {
font-size: 3vh;
}
.centeredBox small{
font-size: 3vw;
}
}
#media screen and (max-width: 800px) {
.oneProject {
margin-bottom: 40%;
}
.projectWrapper {
margin-top: 30%;
}
.logoButton {
filter: blur(0.03em);
-webkit-filter: blur(0.03em);
}
.part5 {
filter: blur(0.06em);
-webkit-filter: blur(0.06em);
}
}
so, I think that it's because you added z-index directly to the about link tag in your css. Try adding z-index to the link wrapper div, in this case "bottomcenterLinks".
.bottomcenterLinks{
position: fixed;
bottom: 5%;
text-align: center;
text-decoration: none;
vertical-align: middle;
display: table-cell;
font-family: "FT88-Italic", sans-serif;
font-size: 3vh;
color: floralwhite;
z-index: 100;
}
now, a feedback for your website design:
it's a pretty innovative design but thinking in user experience i would change the buttons because when we first get into the page we can't understand the purpose of the buttons because they don't have proper names, I mean, self explanatory names. i understand that you wanted to use your name first letters but for the purpose of a portfolio or even another type of website you're building, I think is better building something that will literaly guide the user through the website. think about it!
also, this about link that you're trying to make appear, i think it would be better if you style it like the buttons with your name first letters, it would make it stand out better. oh and i think that instead of having only about, you could have about me written there because when I first saw it I couldn't understand what that about link is supposed to be I mean, is about what, the projects, you, the page?
last but not less important, the blur in your buttons in a user perspective seems like the content is not in a good quality. i don't understand what you wanted it to look like but if you like it that way, no need to change, except if you want to prioritize user exp! besides this, i wouldn't fix anything else, i really enjoyed your design, is cute, innovative, simple, you're doing well!
sry about the big comment tho, but i hope you understand my feedback!
I would like to darken only lower part of the image and ofcourse with linear gradient, so that it goes from light on the top to dark at the bottom of the div.
If there is the other option to do that with div, where the text is there?
Do you need to do that in css or style inside html?
My html code where that background image is:
<div id="content-wide">
<div class="post">
<div class="imgwide" style="background-image: url(image.jpg); background-repeat: no-repeat; background-size: 100%; background-position: center;">
<div class="p-heading"><h1><?php the_title(); ?></h1>
<div class="p-content">
here is the text
</div>
</div>
</div>
</div>
</div>
my style.css contains these entries:
#content-wide {
position: relative;
width: 1180px;
float: left;
background: #F4F4F4;
margin-bottom: 19px;
}
.imgwide {
width: 1160px;
height: 450px;
margin: 10px 10px 10px 10px;
}
#content-wide .post, #content .page {
background-color: #F4F4F4;
}
#content-wide .p-heading {
position: absolute;
bottom: 0;
left:0;
width: 844px;
height: 180px;
}
#content-wide .p-heading h1 {
color: #F8F8F8;
font-size: 26px;
padding: 20px 20px 20px 30px;
}
#content-wide .p-heading h1 a {
color: #F8F8F8;
text-decoration: none;
text-transform: none;
}
#content-wide .p-heading h1 a:hover {
text-decoration: none;
color: #F8F8F8;
}
#content-wide .p-content {
padding: 0px 20px 20px 30px;
font-family: Frutiger, Lato;
font-size: 15px;
line-height: 16px;
text-align: none;
color: #EAEAEA;
}
You can use a CSS solution, check Transparency Gradient, it works like this :
background:linear-gradient(to bottom, rgba(0,0,0,0) 20%, rgba(0,0,0,1)), url('your_url');
This will darken the bottom of your background-image.
If you do not want to darken the image but the div on top of it then use :
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 70%);
on your div (.p-heading).
I received a couple of images and I need them to scale over the whole width of the page, but in height, it should stay the same height for the purposes of the design. (Don't blame me, that's what the designer wants)
I have this HTML:
<section id="fotografie-intro">
<div class="details">
<h1>Fotografie</h1>
<span>Professionele, realistisch foto's gemaakt door een professionele fotograaf.</span>
<span>€ 75 <small>per set</small></span>
</div>
</section>
I have this CSS:
#fotografie-intro {
background: url(../img/unscaledPics/FOTOGRAFIE_headerfoto.jpg);
background-size: 100% 100%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
font-family: 'Titillium Web', sans-serif;
color: rgb(246, 246, 246);
}
#fotografie-intro .details{
background-color: rgba(0, 0, 0, 0.6);
width: 33.333333%;
}
#fotografie-intro h1 {
width: 350px;
font-size: 1.5em;
text-transform: uppercase;
font-weight: 400;
text-align: center;
padding-top: 40px;
z-index: 88;
}
#fotografie-intro span {
display: block;
width: 250px;
padding-top: 20px;
text-align: left;
padding-left: 40px;
font-weight: 100;
}
#fotografie-intro span:last-child {
font-size: 2em;
padding-left: 40px;
}
Above screenshot is how it should not look.
You could go a couple of different ways.
Background-size should do the trick.
background-size:100% 400px;
In the example the width would be 100% and the height would be fixed to 400px
if you want an image to cover it no matter what you could go with
background-position: center;
background-size: cover;
I am trying to have all three spans within an anchor, inline. Not sure what is missing from the code:
a.facebook-button {
float: none;
display: inline-block;
margin-bottom: 5px;
left: auto;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.6);
}
.fb-button-left {
width: 40px;
}
.fb-button-right,
.fb-button-center,
.fb-button-left {
float: left;
height: 40px;
background: url(../img/fb-button.png) left top no-repeat;
}
.fb-button-right {
width: 6px;
background-position: 100% -80px;
}
.fb-button-center {
padding: 0 5px 0 8px;
line-height: 40px;
font-size: 16px;
color: #FFFFFF;
background-color: #6385ba;
background-position: left -40px;
background-repeat: repeat-x;
}
div.socialInvites {
padding: 20px 20px 0px 20px;
text-align: center;
left: auto;
}
<div class="socialInvites">
<a href="main/facebook_request" class="facebook-button" id="facebookbutton">
<span class="fb-button-left"></span>
<span class="fb-button-center"><strong>Connect</strong> with <strong>Facebook</strong></span>
<span class="fb-button-right"></span>
</a>
</div>
Please try adding the following:
display:inline;
Example:
.fb-button-right {
width: 6px;
background-position: 100% -80px;
display:inline;
}
Also, same for the fb-button-center.