Responsive popup window CSS - html

a pop-up window is displayed when the user click to a specific link. . I can not figure out how to make it responsive. On smaller screens, the bottom of the pop-up window is out of range .
HTML code:
<div class="popup-wrapper">
<div class="popup">
<div class="popup-close">x</div>
<div class="popup-content">
<h2>Job Details</h2>
<div class="popup-job-description">
<div class="job-descriptions">
<p><span class="popup-job-description-title">Title: </span>Process Engineer</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-company">Company: </span>Undisclosed</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Location: </span>Naypyitaw</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Salary: </span>$75,000</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-description">Description: </span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa et similique ex, iusto sint in ratione aut magnam! Accusamus eveniet aspernatur nihil? Distinctio vel fugiat eius eaque? Quas earum adipisci quis voluptate animi id atque alias. Sapiente aut explicabo voluptate!</p>
</div>
<div class="job-descriptions requirements">
<p><span class="popup-job-description-requirements">Requirements: </span><ul>
<li>Bachelor's degree</li>
<li>At least 3 years of experience in a similar position</li>
<li>Fluent in English and Mandarin</li>
</ul></p>
</div>
<a class="apply-button" href="#">Apply Now</a>
</div>
</div>
CSS here:
/Job Popup/
.model{
width:100%;
height:100%;
background-color: black;
opacity: 0.5;
position: absolute;
top:0;
}
.popup-wrapper{
opacity: 1;
background: rgba(0,0,0,0.5);
position: fixed;
top:0;
left:0;
width:100%;
height:100%;
display: none;
}
.popup-wrapper .popup{
max-width: 60%;
min-width: 40%;
background: white;
margin: auto auto;
padding: 4rem 2rem 4rem 2rem;
}
.popup-wrapper .popup h2{
text-align: center;
color:#0b1f49;
letter-spacing: 2px;
margin-bottom: 1rem;
}
.popup-wrapper .popup-close{
position:absolute;
top:8%;
right:22%;
cursor:pointer;
font-size: 22px;
}
.popup-wrapper .popup a{
background:#5286ec;
color:white;
text-decoration:none;
padding:20px 35px;
position:relative;
}
.popup-job-description{
align-content:
}
.job-descriptions {
padding:0.75rem;
}
.job-descriptions span{
color:#2260dd;
font-weight: bold;
letter-spacing: 1.5px;
}
.popup-job-description .requirements ul{
margin: 0rem 0rem 2.5rem 1rem;
}
.popup-job-description .requirements li{
font-size: 18px;
margin: 5px;
}
I also have a little problem as you may have notice with the "x" or close-window at the top right of the pop-up window, I used a the absolute value as a display but it seems that it does really work.

Just add overflow-y: scroll; to your .popup-content.
Regarding the close button, you may want to use values in em. Here percentage is percentage of the width for the y coordinate and percentage of height for y coordinate. Since height vary with content, you get unpredictable results.

Related

How to make an image fit its content

[Tree with all its leaves off the brancges[1]
[1]: https://i.stack.imgur.com/hfQGM.png
Im trying to make the image fit to the bottom left and top of the inside border, but not the right i just want it to fit in that certain space.
This is what i have so far...
<section class="winter">
<div class="outside-border">
<div class="section-heading">
<h2>Winter</h2>
</div>
<div class="inside-border">
<div class="winter-image">
<a href="winter.html">
<img src="assets/images/winter.jpg" alt="Winter Image">
</a>
</div>
<div class="section-content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit dolore enim sequi dignissimos vel fugit
reiciendis minus voluptatem nostrum, at repellat odio libero cum eveniet officiis, cumque veritatis, qui
eaque.</p>
</div>
</div>
</div>
css
.outside-border{
border: 2px solid var(--winter-primary);
margin: auto;
max-width: 1000px;
background-color: white;
padding: 20px;
margin-bottom: 20px;
}
.section-heading{
width: 100%;
background-color: var(--winter-primary);
text-align: center;
}
.section-heading>h2 {
margin: 0;
}
.inside-border{
border: 2px solid var(--winter-primary);
display: flex;
align-items: center;
background-color: var(--winter-light);
}
.section-content{
background-color: var(--winter-light);
}
.winter-image{
display: inline-flex;
background-size: cover;
}
p{
margin-left: 1em;
text-align: center;
padding: 10px;
}
Now im just saying the same thing over and over again because im a stupid newbe coder that is having trouble with this problem. Stack overflow says i need to add more words because all i have is code right now.
try to put margin and padding 0.
hope this helps
.winter-image{
display: inline-flex;
background-size: cover;
margin: 0;
padding: 0;
}

How do I horizontally align images? (CSS and HTML)

I am seeking to make a drivers' page. In the desktop view, I would like my images to be next to each other horizontally. Right now, they are vertically aligned.
I have tried changing the display attribute, but it didn't turn out great. The closed thing I have done using the grid display.
I am still fairly new to this. So any help rendered will be appreciated. Thanks!
Here is what my code looks like;
Html Code:
<div class="drivers-container">
<div class="driver-row">
<!--Drivers from Spain-->
<h2><a id="spain" href="#spain">Spain</a></h2>
<div class="image2">
<img src="Drivers/EFREN LLARENA (Spain) 2.jpg" alt="Efren Llarena" width="500">
<div class="details">
<h2><span>Efren Llarena</span></h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nesciunt explicabo perferendis mollitia iste libero magni ab! Ipsam id beatae nesciunt?.</p>
</div>
</div>
<div class="image2">
<img src="Drivers/Sara Fernandez (Spain).jpg" alt="Sara Fernandez" width="500" height="400">
<div class="details">
<h2><span>Sara Fernandez</span></h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nesciunt explicabo perferendis mollitia iste libero magni ab! Ipsam id beatae nesciunt?.</p>
</div>
</div>
</div>
Sara Fernandez (Spain)
Efren-Llarena (Spain)
CSS Code;
.driver-row h2 a{
color: #fff;
text-decoration: none;
font-size: 70px;
font-weight: 300;
}
.drivers-container{
margin: 30px;
}
.driver-row{
width: 100%;
display: grid;
justify-content: center;
flex-wrap: wrap;
}
.image2{
background: #000000;
position: relative;
flex: 1;
max-width: 460px;
height: 300px;
margin: 20px;
overflow: hidden;
}
.image2 img{
opacity: 0.8;
position: relative;
vertical-align: top;
transition: 0.6s;
transition-property: opacity;
}
.image2:hover img{
opacity: 1;
}
.image2 .details{
z-index: 1;
position: absolute;
top: 0;
right: 0;
color: rgb(0, 0, 0);
width: 100%;
height: 100%;
}
.image2 .details h2{
text-align: center;
font-size: 35px;
text-transform: uppercase;
font-weight: 300;
margin-top: 70px;
transition: 0.4s;
transition-property: transform;
}
.image2 .details h2 span{
font-weight: 900;
}
.image2:hover .details h2{
transform: translateY(-30px);
}
.image2 .details p{
margin: 30px 30px 0 30px;
font-size: 18px;
font-weight: 600;
text-align: center;
opacity: 0;
transition: 0.6s;
transition-property: opacity,transform;
}
.image2:hover .details p{
opacity: 1;
transform: translateY(-40px);
}
i recommend you to extract heading and extra stuff from the driver-container
<div class="drivers-container">
<h2>
<a id="spain" href="#spain">Spain</a>
</h2>
<div class="driver-row">
<div class="image2">
<img src="Drivers/EFREN LLARENA (Spain) 2.jpg" alt="Efren Llarena" width="500">
<div class="details">
<h2><span>Efren Llarena</span></h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nesciunt explicabo perferendis mollitia iste libero magni ab! Ipsam id beatae nesciunt?.</p>
</div>
</div>
<div class="image2">
<img src="Drivers/Sara Fernandez (Spain).jpg" alt="Sara Fernandez" width="500" height="400">
<div class="details">
<h2><span>Sara Fernandez</span></h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nesciunt explicabo perferendis mollitia iste libero magni ab! Ipsam id beatae nesciunt?.</p>
</div>
</div>
</div>
now for your css I'll only write down necessary rules, add your own designs later
.driver-row{
display: flex;
flex-wrap: wrap;
width: 100%;
}
.image2{
width: 50%;
box-sizing: border-box;
padding: 20px;
position: relative ;
}
.image2 img{
width:100%;
height: 400px;
object-fit: cover;
}
.image2. details{
position: absolute ;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
it is using flexbox only.

Div goes to the next line in CSS [duplicate]

This question already has answers here:
Two divs side by side - Fluid display [duplicate]
(9 answers)
Closed 1 year ago.
Div with class name main goes to the next line. I don't need it. It's wrong. I've vertical navbar with display block. I don't know why it goes to the next line.
Here's HTML code:
/* Nav */
nav {
padding-left: 30px;
padding-top: 30px;
height: 100vw;
width: 290px;
border-right: 1px solid #333333;
}
.nav__link {
color: #FFFFFF;
width: 250px;
display: block;
border-radius: 8px;
padding: 6px 0px 6px 30px;
transition: background-color .2s linear;
font-family: 'Lato', sans-serif;
font-weight: 700;
font-size: 18px;
margin-top: 20px;
}
.nav__link:hover {
background-color: #707070;
}
/* Main */
.main {
margin-left: 300px;
}
<!-- Nav -->
<nav>
Project 1
Project 2
Project 3
Project 4
</nav>
<!-- Main -->
<div class="main">
<div class="project">
<h1 class="project__name">Project 1</h1>
<p class="project__description">Lorem ipsum, dolor sit amet consectetur adipisicing, elit. Facere voluptates sapiente soluta velit aliquid unde similique quas fugit animi, fugiat, non? At provident totam esse, molestias? Quos, quam. Adipisci, animi.</p>
</div>
</div>
Any ideas to solve this problem, guys?
Add display: flex; to their parent, which is currently <body>:
body {
display: flex;
}
block elements take up entire width, so nav will push the <div> to next line by default.
Side note: I recommend using more semantic elements like <aside> and <main>
/* Nav */
body {
display: flex;
}
nav {
padding-left: 30px;
padding-top: 30px;
height: 100vw;
width: 290px;
border-right: 1px solid #333333;
background: grey;
}
.nav__link {
color: #FFFFFF;
width: 250px;
display: block;
border-radius: 8px;
padding: 6px 0px 6px 30px;
transition: background-color .2s linear;
font-family: 'Lato', sans-serif;
font-weight: 700;
font-size: 18px;
margin-top: 20px;
}
.nav__link:hover {
background-color: #707070;
}
/* Main */
main {
margin-left: 300px;
}
<aside>
<nav>
Project 1
Project 2
Project 3
Project 4
</nav>
</aside>
<!-- Main -->
<main>
<div class="project">
<h1 class="project__name">Project 1</h1>
<p class="project__description">Lorem ipsum, dolor sit amet consectetur adipisicing, elit. Facere voluptates sapiente soluta velit aliquid unde similique quas fugit animi, fugiat, non? At provident totam esse, molestias? Quos, quam. Adipisci, animi.</p>
</div>
</main>

site doesn't scale properly

When I scale my site down or view on mobile/tablet, there is all of this margin/whitespace on right side and it cuts off text content in #main section. Why is this happening and how can I make it all scale correctly? I have tried overflow hidden on various parts which didn't solve anything and I have tried zeroing out margins and messing with padding. I'm unsure how to make it scale correctly and get rid of that extra margin/space on the right. There isnt much yet, only header, nav and #main section.
Thank you for your help in advance
html:
<body>
<header id="main-header">
<div class="container">
<h1 class="display-4">.Richardson</h1>
</div>
</header>
<nav id="navbar">
<div class="container">
<ul class="my-nav">
<li>Home</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</nav>
<section id="main">
<div class="container">
<div class="col-md-8" id="welcome-text">
<h1 class="display-4">Welcome</h1>
<hr class="rule">
<p><cite>"Discipline is the bridge between goals and accomplishments" ~ Jim Rohn</cite></p>
<p>Hey, I'm <span style="font-size: 24px; color: #FFFC31"><strong>Name!</strong></span> Congratulations on joining me in my path to becoming a highly valued, self-taught <span style="font-size: 24px; color:#FFFC31"><strong>Front-End Web Developer</strong></span>. My journey began with <span style="font-size: 24px; color: #FFFC31"><strong>Free Code Camp</strong></span> and the <span style="font-size: 24px; color: #FFFC31"><strong>Code Academy,</strong></span> as well as many youtube tutorials. I've learned <span style="font-size: 24px; color: #FFFC31"><strong>HTML, CSS and Javascript</strong></span> basics thus far. I aspire to put my coding skills to use by adding value and making a difference. Continually challenging myself and improving my craft. <span style="font-size: 24px; color: #FFFC31"><strong>I'm passionate</strong></span> about Nature, animals, traveling, serving the community, maintaining a healthy mind, body and spirit, and enjoying great food and craft beer with great people.</p>
</div>
</div>
</section>
<section>
<h1>Portfolio</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint recusandae, labore, cumque voluptas consequatur excepturi aut qui delectus error harum atque fuga voluptate voluptatibus rem, perferendis laboriosam, pariatur quae hic?</p>
</section>
css:
* {
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin:auto;
overflow: hidden;
}
img {
min-width: 100%;
margin: 0;
}
h1,h2,h3,h4,h5,h6 {
font-family: "Helvetica", "geneva", sans-serif;
}
p {
font-family: sans-serif;
font-size: 1.3rem;
line-height: 2.5rem;
}
a {
color: #4e0250;
}
a:hover {
text-decoration: none;
background-color: gray;
padding: 10px;
color: #D3D3D3;
border-radius: 20px;
}
#main-header {
background: #4E0250;
color: silver;
text-align: center;
position: sticky;
top: 0;
right: 0;
z-index: 1;
}
#navbar {
text-align: center;
background-color: #D3D3D3;
color: #4e0250;
font-size: 1.4rem;
z-index: 1;
}
#navbar ul {
padding-left: 65px;
}
#navbar ul li {
text-align: center;
list-style: none;
padding-right: 40px;
display: inline;
}
#navbar {
position: fixed;
width: 100%;
}
#navbar .my-nav {
margin: 15px;
}
#main {
padding-top: 5rem;
background: url('../img/headon3.jpg') center center no-repeat;
background-size: cover;
min-height: 757px;
overflow: hidden;
}
#main .container {
margin-top: 55px;
margin-left: 150px;
}
#main #welcome-text {
background-color: rgba(92, 92, 92, 0.9);
color: #D3D3D3;
padding: 0 20px;
border-radius: 10%;
padding-bottom: 5px;
min-width: 40%;
}
#main h1 {
padding-top: 20px;
}
.rule {
border-top: 1px solid floralwhite;
padding-bottom: 10px;
}
Your main issue is you're not letting bootstrap take care of margins padding with rows and columns properly. In order to fix this immediate issue you have two problems:
First,
http://getbootstrap.com/docs/3.3/css/#grid-media-queries
#main .container {
margin-top: 55px;
margin-left: 150px;
}
Is getting in the way. Let the .container class take care of itself. It uses media queries to accurately define the margin-left at different widths. What you've done here is hard code it to always be 150px, and on an iphone that is most of the screen.
Second,
http://getbootstrap.com/docs/3.3/css/#grid
Container > rows > columns.
You are missing a row class here:
<div class="container">
<div class="row">
<div class="col-md-8" id="welcome-text">

How to attach footer?

I'm going to make "universal" footer to my example of web-site. But I have any problems:
1. When page is short - footer doesn't work
2. When page is long - footer work
Footer's CSS:
.footer {
text-align: center;
position: relative;
bottom: 0px;
margin-bottom: -50px;
margin-left: -50px;
margin-right: -50px;
width: 110%;
height: 70px;
background-color: #FF9100;
font-size: 20px;
}
Footer's HTML:
<div class="footer">
<p>©All rights reserved</p>
</div>
Examlpes of images:
Try this:
.footer {
text-align: center;
position: fixed;
bottom: 0px;
width: 100%;
height: 70px;
background-color: #FF9100;
font-size: 20px;
}
You can assign position:fixed plus a bottom:0 rules to the .footer section, to force it to stay at the bottom of the page.
You can see a very basic code example below
*{
box-sizing:border-box;
margin:0;
padding:0;
}
main{
background:url('http://lorempixel.com/1200/1200/nature');
background-size:cover;
background-position:center center;
color:#fff;
text-align:center;
height:100vh;
}
footer{
position:fixed;
bottom:0;
}
<main>
<h1>Example page</h1>
<footer>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur molestias quos, soluta. Ut dolorum officia illum molestias quia commodi tempora cupiditate, earum deleniti amet sequi deserunt tempore, perferendis harum doloremque.</p>
</footer>
</main>