Popup Images Different sizes - html

I am working this popup section. On larger screens there are 2 images stacked on the left. When the screen is smaller (tablet/phone) they are side by side.
I cannot find whats wrong here, but my images are different sizes. On the large screen I notice a 1px white line on the left side. On the smaller screens its off on the top.
I noticed the pictures are slightly different sizes. I went back through the my code to see if I could notice anything that was adding this extra white space, but I can't see anything besides the different photo ratios (2000X1333px) and (2000X1376px)...
I am following a video and the persons images seem to be the same size?
Photos and code attached, help very much appreciated!
Large screen
Small Screen
Codepen Link for extra CSS/HTML It may help with clarity, although it doesnt have the images for the visual problem.
<div class="popup__left">
<img src="img/nat-8.jpg" alt="Tour Photo" class="popup__img">
<img src="img/nat-9.jpg" alt="Tour Photo" class="popup__img">
</div>
<div class="popup__right">
×
<h2 class="heading-secondary">Start booking now</h2>
<h3 class="heading-tertiary">Important – Please read the terms and conditions first</h3>
<p class="popup__text">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Cum molestias recusandae id consequuntur odio alias dolores culpa reiciendis hic incidunt eos ipsa qui, doloribus consequatur voluptas enim obcaecati laborum mollitia aperiam ut. Molestias dicta, ipsa iusto esse commodi neque unde ipsam dolor quasi? Expedita, earum nemo? Soluta aspernatur nulla, doloremque harum, corrupti unde adipisci id officiis repudiandae vel, odio mollitia. Ab esse placeat quod earum aliquid iure! Ipsum assumenda, recusandae quia perspiciatis maiores quos sunt? Molestiae unde deleniti id repudiandae porro et, incidunt explicabo, similique quibusdam voluptatum a, sunt impedit?</p>
Book now!
</div>
</div>
</div>
.popup {
height: 100vh;
width: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba($color-black, .8);
z-index: 9999;
visibility: hidden;
opacity: 0;
transition: all .3s;
&__content {
#include absCenter;
width: 75%;
background-color: $color-white;
box-shadow: 0 2rem 4rem rgba($color-black, .2);
border-radius: 3px;
display: table;
overflow: hidden;
opacity: 0;
transform: translate(-50%, -50%) scale(.25);
transition: all .4s .2s;
}
&__img {
display: block;
width: 100%;
#include respond(tab-port) {
display: inline-block;
width: 49%;
}
}
&__left {
width: 33.333333%;
display: table-cell;
#include respond(tab-port) {
display: block;
width: 100%;
padding: 3rem 5rem 0rem 5rem;
}
}
&__right {
width: 66.666667%;
padding: 3rem 5rem;
display: table-cell;
vertical-align: middle;
#include respond(tab-port) {
display: block;
width: 100%;
}
}
&__text {
font-size: 1.4rem;
margin-bottom: 4rem;
-moz-column-count: 2;
-moz-column-gap: 4rem;
-moz-column-rule: 1px solid $color-gray-light-2;
column-count: 2;
column-gap: 4rem;
column-rule: 1px solid $color-gray-light-2;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
#include respond(tab-port) {
-moz-column-count: 1;
column-count: 1;
}
}
//Popup open state
&:target {
visibility: visible;
opacity: 1;
}
&:target &__content {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
&__close {
&:visited,
&:link {
color: $color-gray-dark;
position: absolute;
top: 2.5rem;
right: 2.5rem;
font-size: 3rem;
text-decoration: none;
display: inline-block;
transition: all .3s;
line-height: 1;
}
&:hover {
color: $color-primary;
}
}
}

You are using popup__left width=33.33% and popup__img width=100% and the 100% of image is bigger then 33% of your screen. Try to set overflow:hidden on the popup__left (needs to define width and height).
If it doesn't work, try to set z-index:1 to left and z-index:0 to the right because that line is from the border of popup__text (column-rule: 1px solid $color-gray-light-2).

Related

Is there a way to place text over image without background-image, or position: relative?

My situation is that I don't want it as a background-image because I'm changing the opacity on hover, and so that it didn't affect the text as well I made them separate elements.
However, moving them using position: relative; means that I am left with blank space where their supposed to be in page flow.
Any help would be greatly appreciated.
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
width: 100%;
}
div {
width: 24%;
min-width: 400px;
height: 25em;
transition: 200ms;
margin: 1rem 0;
}
div.background-img {
width: 100%;
height: 100%;
}
#img-1 {
background-image: url("imgs/tokyo.jpg");
}
/* Later in code */
.background-img:hover {
transition: 200ms;
filter: brightness(50%);
outline: 1px white solid;
outline-offset: -20px;
border-radius: 5%;
}
div .hidden-text {
transition: 200ms;
position: relative;
bottom: 100%;
color: white;
opacity: 0;
pointer-events: none;
}
div:hover .hidden-text {
transition: 200ms;
color: rgb(255, 255, 255, 1);
opacity: 1;
}
<section class="flex-container">
<div>
<h1>Holiday Destinations</h1>
<span>This is a collection of locations that I either would love to visit, or loved visiting.</span>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat totam
eum asperiores assumenda, amet rem molestiae pariatur at nulla sequi
debitis itaque voluptatem modi corrupti fugiat sed quod dolores
perspiciatis maiores in! Tenetur molestiae eum cupiditate obcaecati
consectetur. Culpa consequatur doloribus, non voluptates quia commodi
dolore mollitia cupiditate modi dolorem?
</p>
</div>
<div>
<div class="background-img" id="img-1"></div>
<h2 class="hidden-text">Tokyo - Japan</h2>
<p class="hidden-text">Lorem ipsum dolor sit amet.</p>
</div>
</section>
Website here --> https://dex-hewitt.github.io/holiday-destinations
Thank you!
Also please let me know if I've written question poorly or not included any necessary parts I am new to stackoverflow.
You can approach it this way if you don't want it to be as a background. Let me know
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
width: 100%;
}
div {
width: 24%;
min-width: 400px;
height: 25em;
transition: 200ms;
margin: 1rem 0;
}
div.background-img {
width: 100%;
height: 100%;
}
div img {
width: 500px;
height: 500px;
object-fit: cover;
}
/* Later in code */
.background-img:hover {
transition: 200ms;
filter: brightness(50%);
outline: 1px white solid;
outline-offset: -20px;
border-radius: 5%;
}
div .hidden-text {
transition: 200ms;
position: relative;
bottom: 100%;
color: white;
opacity: 0;
pointer-events: none;
text-align: center;
}
div:hover .hidden-text {
transition: 200ms;
color: rgb(255, 255, 255, 1);
opacity: 1;
}
<section class="flex-container">
<div>
<h1>Holiday Destinations</h1>
<span>This is a collection of locations that I either would love to visit, or loved visiting.</span>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat totam
eum asperiores assumenda, amet rem molestiae pariatur at nulla sequi
debitis itaque voluptatem modi corrupti fugiat sed quod dolores
perspiciatis maiores in! Tenetur molestiae eum cupiditate obcaecati
consectetur. Culpa consequatur doloribus, non voluptates quia commodi
dolore mollitia cupiditate modi dolorem?
</p>
</div>
<div>
<img class="background-img" src="https://thumbs.dreamstime.com/b/shinjuku-gyoen-national-garden-tokyo-japan-large-park-shibuya-lake-asian-153188061.jpg" >
<h2 class="hidden-text">Tokyo - Japan</h2>
<p class="hidden-text">Lorem ipsum dolor sit amet.</p>
</div>
</section>
Sorry all, a typo mistake on my end. While I thought it was the texts border box causing the blank space, I found it to be a missing "/" symbol on a lower div.

Carousel indicators WITHOUT bootstrap and WITHOUT any function

I've seen a LOT of examples for making carousel indicators for a pictures gallery. But all of them were using bootstrap or radio buttons (for jumping to another pic). I don't want that.
Given the code below, is there a way to show the user which of the 3 pictures is he/she currently viewing? I don't want the user to be able to click the indicator to jump to another picture. I just want to highlight the indicator so he/she knows "ok then, I'm on the second picture".
I want to use this thing ONLY on mobile and tablet, then with media queries I will change it on desktop.
NOTE: I am a beginner, I know how to work with HTML and CSS only...I'm sure there are plenty of ways to do that using JS...but I wouldn't understand them.
Here is the page in question so you can see how it behaves. IMPORTANT: Inspect it with mobile simulator to see the behavior, 'cause the code snippet won't work properly here.
.sezionecane {
margin-top: 1.5em;
}
.nomecane {
text-align: center;
margin-bottom: .5em;
}
.immaginicane {
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
margin-bottom: 1em;
}
.immaginicane::-webkit-scrollbar {
display: none;
}
.immaginicane > img {
scroll-snap-align: start;
}
<div class="sezionecane">
<h3 class="nomecane">Osso</h3>
<div class="immaginicane">
<img id="foto1" src="cani/foto1.jpg" width="100%" alt="foto1">
<img id="foto2" src="cani/foto2.jpg" width="100%" alt="foto2">
<img id="foto3" src="cani/foto3.jpg" width="100%" alt="foto3">
</div>
<p class="testocane">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi soluta, dolore! Sed aliquid assumenda exercitationem dolores numquam, at rerum quia, ducimus impedit consequuntur! Rem illo debitis beatae quas modi similique nemo, minima atque natus laborum. Aperiam, rerum et nesciunt ullam?</p>
</div>
Not solved (currently). You can click #foto1 and it'll change the color of #foto2 (or #foto3) but not previous element nor what is outside its parent like the dots. Apart of that, it does looks fine in mobile.
The ~.dots#dot-s are probably needed to be placed inside of .immaginicane, but that does’t seems to work.
<style>
.sezionecane{
margin-top: 1.5em;
}
.nomecane{
text-align: center;
margin-bottom: .5em;
}
.immaginicane{
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
margin-bottom: 1em;
z-index: 10;
}
.immaginicane::-webkit-scrollbar{
display: none;
}
.immaginicane > img{
scroll-snap-align: start;
}
#foto1, #foto2, #foto3{
height: 55vh;width: 100vw;
display: block;position: relative;
}
#foto1::before{
content: "";
height: 0px;width: 0px;
top: 46%;right: 10px;
display: block;position: absolute;
opacity: 0.7;
border: 10px solid transparent;
border-left: 10px solid #72DAFF;
}
#foto1::after{
content: "foto 1";
color: #72DAFF;
top: 6px;left: 12px;
display: block;position: absolute;
opacity: 0.7;
}
#dots{
width: 100%;height: 12px;
display: flex;position: relative;flex-direction: row;
align-items: center;justify-content: center;
z-index: 11;
}
.dot{
background-color: #EEE;
width: 10px;height: 10px;
margin-right: 5px;margin-left: 5px;
display: block;position: relative;
border-radius: 50%;
}
#foto1:hover~#foto2{
background-color: #72DAFF;
}
#foto2:hover~#dot-2{
background-color: #72DAFF;
}
#foto3:hover~#foto-2{
background-color: #72DAFF;
}
</style>
<div class="sezionecane">
<h3 class="nomecane">Osso</h3>
<div class="immaginicane">
<img id="foto1" src="" width="100%" alt="foto1">
<img id="foto2" src="" width="100%" alt="foto2">
<img id="foto3" src="" width="100%" alt="foto3">
</div>
<div id="dots"><div class="dot" id="dot-1"></div><div class="dot" id="dot-2"></div><div class="dot" id="dot-3"></div></div>
<p class="testocane">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi soluta, dolore! Sed aliquid assumenda exercitationem dolores numquam, at rerum quia, ducimus impedit consequuntur! Rem illo debitis beatae quas modi similique nemo, minima atque natus laborum. Aperiam, rerum et nesciunt ullam?</p>
</div>

How to remove space between div elements? [duplicate]

This question already has answers here:
CSS margin terror; Margin adds space outside parent element [duplicate]
(7 answers)
Closed 2 years ago.
I have two div elements and I want to remove the space between them, which is filled with the background color at the moment. This is what it looks like. I want to remove the space between the green section and where the background image ends for the first div element. Here is the HTML for the page:
<body style="background-color: #c5ffff">
<div class="main-search hero-image">
Log Out
<div class="welcome-text">
<div class="title">Welcome to Ripple.</div>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A aliquam commodi doloremque esse itaque iusto, labore laborum maxime odio, quidem quos, repellat rerum? Ab, asperiores aspernatur assumenda atque distinctio dolor dolore eveniet facilis, id illo ipsa ipsam minus nemo nobis porro quam quia quibusdam quis ratione rerum soluta suscipit temporibus vel vitae voluptate. Accusamus dignissimos ea esse expedita itaque mollitia nobis, numquam odio, quaerat qui vel voluptatibus?</div>
<button class="search_button" >Search for a location</button>
<button class="search_button">Search for a song</button>
</div>
</div>
<div class="main-left">
<div class="title">Collections Near Me</div>
<div>
</div>
</body>
And the CSS:
.main-left {
vertical-align: top;
margin-top: 0;
margin-left: 0;
position: relative;
background-color: #85dcba;
text-align: left;
width: 100%;
float: top;
left: 50%;
transform: translate(-50%);
}
.main-search {
vertical-align: top;
background-color: #d2fdff;
text-align: left;
margin: 0;
padding-top: 2em;
position: relative;
top: 0;
width: 100%;
left: 50%;
transform: translate(-50%);
}
.hero-image {
background-image: url("main_background.jpg");
background-size: cover;
background-repeat: no-repeat;
}
.title {
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0.5em;
margin-left: 10px;
margin-bottom: 0.5em;
}
.content {
color: black;
font-family: Roboto, sans-serif;
font-size: 1em;
margin: 1em;
}
.welcome-text {
top: 5%;
left: 5%;
max-width: 35%;
}
There is a gap because div is block element, if you want to remove the gap between div use display: inline-block to remove it.
body > div { display: inline-block; }
This will display an element as an inline-level block container. Please refer to CSS Display
You could try setting the margin values of the elements manually. I see you've set the padding- Which refers to the internal distance of contents to edge, but not the margin- which refers to the distance between seperate elements.
Also, nice looking design so far!
Display flex has a nifty way of removing undesirable whitespace from the html
So place flex on the wrapper of these elements, in this case the body tag
css
body {
display: flex;
flex-direction: column;
}
Set margin-top of the .title to zero and for space between the .main-search and .title, give padding-bottom to .main-search as well. Below is how it will look like:
body{
background-color: #c5ffff;
}
.main-left{
vertical-align: top;
margin-top: 0;
margin-left: 0;
position: relative;
background-color: #85dcba;
text-align: left;
width: 100%;
float: top;
left: 50%;
transform: translate(-50%);
}
.main-search{
vertical-align: top;
background-color: #d2fdff;
text-align: left;
margin: 0;
padding: 2em 0;
position: relative;
top: 0;
width: 100%;
left: 50%;
transform: translate(-50%);
}
.hero-image{
background-image: url("https://picsum.photos/500/500");
background-size: cover;
background-repeat: no-repeat;
}
.title{
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0;
margin-left: 10px;
margin-bottom: 0.5em;
}
.content{
color: black;
font-family: Roboto, sans-serif;
font-size: 1em;
margin: 1em;
}
.welcome-text{
top: 5%;
left: 5%;
max-width: 35%;
}
<div class="main-search hero-image">
Log Out
<div class="welcome-text">
<div class="title">Welcome to Ripple.</div>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A aliquam commodi doloremque esse itaque iusto, labore laborum maxime odio, quidem quos, repellat rerum? Ab, asperiores aspernatur assumenda atque distinctio dolor dolore eveniet facilis, id illo ipsa ipsam minus nemo nobis porro quam quia quibusdam quis ratione rerum soluta suscipit temporibus vel vitae voluptate. Accusamus dignissimos ea esse expedita itaque mollitia nobis, numquam odio, quaerat qui vel voluptatibus?</div>
<button class="search_button" >Search for a location</button>
<button class="search_button">Search for a song</button>
</div>
</div>
<div class="main-left">
<div class="title">Collections Near Me</div>
<div>
remove margin-top:0.5em; on your title class.
.title {
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0.5em; <-- REMOVE
margin-left: 10px;
margin-bottom: 0.5em;

Align DIV Tags Horizontally [duplicate]

This question already has answers here:
How can I rotate the elements in my navbar using CSS?
(2 answers)
Closed 3 years ago.
I have some div tags which I am using as contact links on my website. They are meant to be located on the right hand side and be aligned in one line.
Currently looks like:
Preferred alignment:
Code below:
#book-me {
position: fixed;
right: 0;
transform: translateY(-50%);
z-index: 99999;
top: 50%;
background: black;
color:white;
padding: 5px 10px;
}
#book-me a {
background: black;
color: white;
display: inline-block;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
font-family: sofia-pro;
writing-mode: vertical-rl;
}
#media screen and (max-width: 960px) {
#book-me {
bottom: 0;
top: initial;
transform: none;
}
#book-me a {
writing-mode: initial;
padding: 5px 10px;
}
}
<div id="book-me">
Call,
Text or
WhatsApp
</div>
Why not just rotate your book-me div (use full screen on snippet below to see transform):
#book-me {
position: fixed;
right: 0;
transform: rotate(90deg);
transform-origin: top right;
z-index: 99999;
bottom: 0;
background: black;
color: white;
padding: 5px 10px;
}
#book-me a {
background: black;
color: white;
display: inline-block;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
font-family: sofia-pro;
}
#media screen and (max-width: 960px) {
#book-me {
transform: none;
}
#book-me a {
padding: 5px 10px;
}
}
<div id="book-me">
Call,
Text or
WhatsApp
</div>
<a> tags are only used to apply links to text, so they do not format the text on a block-level in any way. Format them as divs to get the effect you want. Note that this code does not contain anything to rotate the text 90 degrees as I assume based on your screenshots you already wrote that elsewhere.
#book-me {
position: fixed;
right: 0;
transform: translateY(-50%);
z-index: 99999;
top: 50%;
background: black;
color:white;
padding: 5px 10px;
}
#book-me a {
background: black;
color: white;
display: inline-block;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
font-family: sofia-pro;
writing-mode: vertical-rl;
}
#media screen and (max-width: 960px) {
#book-me {
bottom: 0;
top: initial;
transform: none;
}
#book-me a {
writing-mode: initial;
padding: 5px 10px;
}
}
<div id="book-me">
<div>Call</div>,
<div>Text</div>
<div>or</div>
<div>WhatsApp</div>
</div>
Below is the Code you were probably trying to achieve but to be honest this is less than ideal and I would recommend just rotate your box since your approach isn't meant to be used like that.
* {
margin: 0;
padding: 0;
}
#book-me {
position: fixed;
height: 100%;
left: 0;
z-index: 99999;
display: flex;
justify-content: center;
align-items: baseline;
}
#book-me span {
transform: translateY(calc(50vh - 50%));
color: white;
background: black;
padding: 5px 10px;
writing-mode: vertical-rl;
}
#book-me a {
background: black;
color: white;
display: inline-block;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
font-family: sofia-pro;
writing-mode: vertical-rl;
}
#media screen and (max-width: 960px) {
#book-me {
bottom: 0;
top: initial;
transform: none;
}
#book-me a {
padding: 5px 10px;
}
}
p {
padding: 2em;
font-size: 2em;
}
<div id="book-me">
<span>
Call,
Text or
WhatsApp
</span>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas, doloremque!</p>
<p>Expedita fugit dolor amet ipsa voluptatibus, nesciunt eos beatae voluptas.</p>
<p>Vitae sapiente, nihil ea quam, asperiores error aliquam? Mollitia, nobis?</p>
<p>Veniam suscipit explicabo ipsum nobis hic sunt, ea laboriosam obcaecati!</p>
<p>Sunt explicabo consectetur eius ipsam maiores laborum inventore excepturi temporibus?</p>
<p>Blanditiis nulla tenetur, cum, placeat fuga sint sed itaque debitis.</p>
<p>Fugit nobis fuga sit, repellat quae doloremque, dolorum obcaecati suscipit!</p>
<p>Voluptas officiis veritatis excepturi possimus modi eum corporis, ducimus earum!</p>
<p>Dolorem expedita quae, numquam consequatur maiores veniam iure? Minus, quia?</p>
<p>Deserunt fugiat odit repellat impedit perferendis, minus minima. Facere, quidem.</p>

CSS - Unable to align image and text together inside div

I'm trying to show message within a div with icon on the left.
Expected result is icon should always adjacent to text and together they need to be aligned at bottom-center of div.
I'm using :after pseudo element. Keeping position: absolute of icon didn't help since that needs manually adjusting the icon position relative to text.
Here is the CSS.
.parent{
font-weight: 500;
height: 65px;
text-align: center;
padding: 15px 0 10px;
margin: auto;
display: block;
width: 80%;
font-size: 12px;
overflow: hidden;
position: relative;
}
.parent > div {
float: none;
/* display: table-cell; */
vertical-align: middle;
position: absolute;
bottom: 0;
width: 100%;
}
.msg:after {
content: '';
background: url(data:image/...);
height: 16px;
width: 16px;
display: block;
position: absolute;
top: 0;
padding-right: 5px;
left: 108px;
}
And markup:
<div class="parent">
<div class="msg">text goes here</div>
</div>
Flexbox can do that:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
::before,
::after {
box-sizing: inherit;
}
.parent {
font-weight: 500;
margin: auto;
padding: 1em;
width: 80%;
font-size: 12px;
overflow: hidden;
position: relative;
border: 1px solid red;
}
.msg {
display: flex;
}
.msg p {
padding-left: 1em;
}
.msg:before {
content: "";
height: 16px;
flex: 0 0 16px;
background: red;
border-radius: 100%;
}
<div class="parent">
<div class="msg">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae numquam unde, eum sequi expedita fugiat ipsa exercitationem nesciunt libero repellendus aperiam excepturi, dolorem repudiandae eveniet alias perspiciatis, vero veniam tempora natus magnam
itaque quos. Nemo sit nisi, veniam mollitia fugit eaque reiciendis ex doloribus rem et suscipit debitis commodi sapiente.</p>
</div>
</div>