Div with background image and display flex moves when modal is closed - css

I have a row of thumbnails, with an animated title centered with display: flex.
When a thumbnail button is clicked a modal appears with a slideshow. After the modal is closed, the thumbnail of the selected gallery is shifted out of place.
I've done extensive css debugging on this and didn't find anything conclusive. I'm thinking its a side affect of Bootstrap modal JS or something to do with display: flex - display: block switch on hover.
.gallery-top {
height: 220px;
margin-bottom: 10px;
.swiper-slide {
width: 100%;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
position: relative;
z-index: 1;
border-right: 3px solid #fff;
}
}
.gallery-row {
padding: 0 0 0 2px;
}
.gallery-thumbs {
height: 90px;
.swiper-slide {
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
position: relative;
z-index: 1;
border-right: 3px solid #fff;
}
}
.galleryThumbs {
div.galleryThumbWrapper {
padding-right: 2px;
padding-bottom: 2px;
>div {
width: 100%;
height: 100%;
}
}
.cta_box {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
text-align: center;
color: white;
background: rgba(138, 196, 64, 0.6);
z-index: 2;
.cta_holder {
padding-bottom: 20px;
.title {
font-size: 1.2em;
line-height: 1em;
padding: 20px 20px 10px 20px;
font-family: proxima-nova;
font-weight: 600;
color: white;
text-transform: uppercase;
margin: 20px 0 0 0;
}
.button {
cursor: pointer;
color: white;
background: transparent;
border: 1px solid #fff;
border-radius: 30px;
display: inline-block;
padding: 3px 16px;
font-family: proxima-nova;
font-weight: 600;
font-size: 1em;
text-transform: uppercase;
}
}
}
&:last-child {
border: 0;
}
}
#media screen and (min-width: 768px) {
.gallery-top {
height: 320px;
}
}
#media screen and (min-width: 1024px) {
.col-lg-5ths {
width: 20%;
flex: 0 0 20%;
}
.gallery-top {
height: 420px;
}
.galleryThumbs {
.cta_box {
display: block;
justify-content: center;
align-items: center;
top: 100%;
transition: top 0.75s;
}
&:hover .cta_box {
top: 0;
display: block;
.cta_holder {
display: block;
}
}
}
}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<div class="row gallery-row">
<div class="col-12 col-md-6 col-lg-5ths galleryThumbs embed-responsive embed-responsive-1by1">
<div class="embed-responsive-item galleryThumbWrapper">
<div style="background: url('http://lorempixel.com/400/400/') no-repeat center center; background-size: cover;">
<div class="cta_box">
<div class="cta-content">
<div class="cta_holder">
<p class="title">Headline 1</p>
<div>
<button type="button" class="button" data-toggle="modal" data-target="#galleryModal" data-gallery="{{gall.uri}}">View Project</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="galleryModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<p>
My Modal
</p>
</div>
</div>
</div>
Here is a fiddle.
https://jsfiddle.net/sdetcp51/

This is because on #media screen and (min-width: 1024px), you set the top of .cta_box to 100%, which pushes the box to the bottom, but then you still have its bottom set to 0 from previous styles. That basically makes the box 0 height. Hence its content will overflow.
The move of the background image after modal is closed is due to the box content overflow.
The fix is easy. Just add overflow: hidden; on the .cta_box.
Fiddle: https://jsfiddle.net/sdetcp51/54/

Related

How to create CSS Buttons that appear on hover within a flex container?

I'm trying to put some buttons onto some flex containers for a sort of middle-of-the-page dropdown menu. I need four buttons that fill the space of the flex container, that appear on hover. I can get the hover action working, but my buttons don't show up and are a little off. I'm very new at this and have really hit a wall here.
Essentially, I need a box that splits into 4 other clickable boxes on hover, all contained inside the original box.
.nav-box-container {
width: 220px;
margin: 15px 7px 0px 7px;
flex-grow: 1;
}
#media (max-width: 767px) {
.nav-box-container {
width: auto;
}
.nav-box-citations {
color: #282828;
background-color: #fff;
outline: 3px solid #bbb;
margin: 0px;
padding: 25px 25px 30px 25px;
padding-right: 19px;
min-height: 160px;
font-size: 17px;
font-weight: 500;
height: 100%;
}
.nav-box-citations-buttons {
display: none;
width: 100%;
background-color: #fff;
outline: #282828 solid;
text-decoration: none;
}
.nav-box-citations:hover,
.nav-box-citations:focus+.nav-box-citations-buttons,
.nav-box-citations-buttons:hover {
display: inline;
}
<div class="nav-box-container">
<div class="nav-box-citations">
<h3 class="nav-box-title">Citation Guides</h3>
<p class="nav-box-desc">Get help on formatting citations and bibliographies.</p>
<div class="btn-grp">
<button type="button-group" class=nav-box-citations-buttons>APA</button>
<button type="button-group" class=nav-box-citations-buttons>MLA</button>
<button type="button-group" class=nav-box-citations-buttons>AMA</button>
<button type="button-group" class=nav-box-citations-buttons>Chicago</button>
</div>
</div>
</div>
Produces this:
The trick is to target just the children of the hovered parent:
.nav-box-citations:hover .nav-box-citations-buttons {
display: inline;
}
.nav-box-container {
width: 220px;
margin: 15px 7px 0px 7px;
flex-grow: 1;
}
#media (max-width: 767px) {
.nav-box-container {
width: auto;
}
.nav-box-citations {
color: #282828;
background-color: #fff;
outline: 3px solid #bbb;
margin: 0px;
padding: 25px 25px 30px 25px;
padding-right: 19px;
min-height: 160px;
font-size: 17px;
font-weight: 500;
height: 100%;
}
.nav-box-citations-buttons {
display: none;
width: 100%;
background-color: #fff;
outline: #282828 solid;
text-decoration: none;
}
.nav-box-citations:hover .nav-box-citations-buttons {
display: inline;
}
<div class="nav-box-container">
<div class="nav-box-citations">
<h3 class="nav-box-title">Citation Guides</h3>
<p class="nav-box-desc">Get help on formatting citations and bibliographies.</p>
<div class="btn-grp">
<button type="button-group" class=nav-box-citations-buttons>
APA
</button>
<button type="button-group" class=nav-box-citations-buttons>
MLA
</button>
<button type="button-group" class=nav-box-citations-buttons>
AMA
</button>
<button type="button-group" class=nav-box-citations-buttons>
Chicago
</button>
</div>
</div>
</div>

Angular - how to remove white background in modal form with round corners

when opening a modal form with round corners I wish to remove the white background
This is my css for the modal form
.modal-msg {
.modal-dialog {
width: 25vw !important;
max-width: 35vw !important;
}
.form-msg {
box-shadow: -20px 20px 30px 0 rgba(0, 0, 0, 0.16);
background-image: linear-gradient(41deg, #40d2ea, #964ada 54%, #7d2abd 77%, #7c29bb 77%, #541b7e 91%);
color: #fff;
overflow: hidden;
border-radius: 120px;
background-radius: 120px;
.modal-header {
border: none;
padding-bottom: 0 !important;
justify-content: space-around;
.close-icon {
background-image: url('close.svg');
width: 20px;
height: 20px;
background-repeat: no-repeat;
background-size: contain;
margin-left: 10px;
z-index: 100;
&:focus {
outline: none;
}
}
.header {
font-size: 33px;
font-weight: 600;
}
}
.modal-body {
padding: 1rem 12%;
.header {
font-size: 33px;
font-weight: 600;
direction: rtl;
margin-bottom: 1rem;
}
.form-control {
color: #112d60;
font-weight: 600;
&:focus {
border-color: #112d60 !important;
}
}
}
.background {
width: 100%;
position: relative;
.circle {
position: absolute;
}
}
}
}
I've tried setting the background to transparent and playing with background-clip I guess I'm using it wrong or in not in the right order
please advice,
cheers.
the html code using this is:
<div class="form-msg">
<div class="background">
<div class="circle left-circle"></div>
<div class="circle right-circle"></div>
</div>
<div class="modal-header">
<button type="button" class="close" aria-label="Close" (click)="close()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12 text-center header">
<span class="inspire-text">Inspiration Msg</span>
</div>
</div>
</div>
</div>
I finally figured it out and overloaded modal-content like this
.modal-content{
background-color: transparent;
border:none !important;
}

How to maintain a circlur shape of element with dynamic content?

I'm trying to create a circle as an ::after pseudo element, which resizes automatically depending on its content.
.container {
display: flex;
flex-direction: row;
}
#dividerHost2 #left {
flex: 1 1 auto;
background-color: yellowgreen;
height: 200px;
}
#dividerHost2 #right {
flex: 1 1 auto;
background-color: dodgerblue;
}
#dividerHost2 .divider {
background-color: white;
margin: 0px;
width: 6px;
font-weight: 800;
}
.divider.vertical {
--divider-color: transparent;
display: inline-flex;
width: 1px;
border-left: 1px solid rgb(var(--divider-color));
margin: 0px 2px 0px 2px;
overflow: show;
}
.divider.vertical.title::after {
flex: 0 0 auto;
align-self: center;
border-radius: 50%;
content: "OR";
padding: 9px 8px 11px 8px;
background-color: white;
color: black;
transform: translateX(-44%);
z-index: 10;
}
<div id="dividerHost2" class="container">
<div id="left" class="container" style="flex-direction: row;"></div>
<div id="divider3" class="divider vertical title"></div>
<div id="right" class="container" style="flex-direction: row;"></div>
</div>
That gives a pretty nice result so far:
JSFiddle https://jsfiddle.net/jsnbtmh3/
However, with longer text the circle turns into an oval:
How to make the circle auto resize depending on its content?
Here is a trick using radial-gradient. The idea is to keep the element full height and color it using circle closest-side which will always create a circle that will start from the center and expand to the closest sides (left and right one)
I simplified the code to keep only the relevant part:
.container {
display: flex;
flex-direction: row;
margin:10px;
}
.left {
flex: 1 1 auto;
background-color: yellowgreen;
height: 200px;
}
.right {
flex: 1 1 auto;
background-color: dodgerblue;
}
.divider {
background-color: white;
width: 6px;
font-weight: 800;
display: flex;
justify-content: center;
}
.divider::after {
display: flex;
align-items: center;
flex: 0 0 auto;
content: attr(data-text);
padding: 0 8px;
background: radial-gradient(circle closest-side, white 98%, transparent 100%);
z-index: 10;
}
<div class="container">
<div class="left "></div>
<div class="divider" data-text="OR"></div>
<div class="right "></div>
</div>
<div class="container">
<div class="left "></div>
<div class="divider" data-text="longer"></div>
<div class="right "></div>
</div>
<div class="container">
<div class="left "></div>
<div class="divider" data-text="even longer"></div>
<div class="right "></div>
</div>
Don't put actual content in the pseudo-element especially as this is actually "content" rather than styling, rather use the pseudo-element to create a background circle using the padding/aspect ratio trick.
body {
text-align: center;
}
.divider {
margin: 3em;
display: inline-block;
position: relative;
padding: 1em;
font-weight: bold;
}
.divider:after {
content: "";
position: absolute;
width: 100%;
padding-top: 100%;
background: lightblue;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: -1;
}
<div class="divider">OR</div>
<div class="divider">LONG TEXT</div>

How would I get a text-align:right object to be centered on mobile in Twitter Bootstrap?

I would like to put a header and a button on the same horizontal line but on opposite sides of the page (left and right). I'm using Twitter Bootstrap so I've put them in a .row and then specified that they each are .col.sm-6. I put the button in a div, so I could move it to the right of that column with text-align:right.
How could I make that button center itself on mobile? When the window gets smaller and the second column jumps under the first, the button is still right-aligned.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<div class="row">
<h1 class="col-sm-6">Resources</h1>
<div class="col-sm-6" style="margin-top: 20px">
<button style="text-align:right">Sign up your event</button>
</div>
</div>
You can define a class for your button like <button class="button">Sign up your event</button> and then use #media-queries to center it using the following CSS when the window size is reduced to mobile width, like this:
#media (max-width: 768px) {
.button {
display: block;
margin: 0px auto;
}
}
Here's a working demo (view as full page and then reduce your browser window):
.outfitcontainer {
position: relative;
width: 200px;
height: 80%;
background-color: #FFFFFF;
display: inline-block;
margin-left: 60px;
margin-top: 20px;
margin-bottom: 20px;
padding: 20px;
}
.outfit img {
display: inline-block;
}
.outfit,
.overlay {
position: absolute;
width: 200px;
height: auto;
left: 0;
}
.outfit {
z-index: 10;
background-color: white;
}
.outfitcontainer:hover .outfit {
opacity: .5;
cursor: pointer;
}
.outfit:hover + .overlay {
z-index: 50;
}
.overlay:hover {
z-index: 50;
}
.overlay {
z-index: 0;
text-align: center;
font-weight: bold;
}
.overlay p {
display: block;
padding: 10px 0;
color: black;
opacity: 1;
line-height: 50%;
}
.overlay p:nth-child(1) {
margin-top: 50%
}
.price,
.item {
font-family: "Brandon Grotesque Medium";
font-size: 1em;
color: #000000;
line-height: 25%;
margin-top: -10px;
}
.oldprice {
text-decoration: line-through;
color: #383838;
font-size: .75em;
line-height: 25%;
}
.designer {
font-family: "Didot Light Italic";
font-size: 1em;
color: #000000;
line-height: 25%;
margin-top: -15px;
}
.second-section {
width: 100%;
height: auto;
z-index: 50;
background-color: #000000;
}
.button {
text-align: right;
}
#media (max-width: 768px) {
.button {
display: block;
margin: 0px auto;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<h1 class="col-sm-6">Resources</h1>
<div class="col-sm-6" style="margin-top: 20px">
<button class="button">Sign up your event</button>
</div>
</div>

How do I create a Zomato style search bar?

I want to crate a search bar similar to that of https://www.zomato.com/ Exactly the same layout.
I am able create a floating search box on top of my background image. Not sure how to join various input fields and button side by side. This is the css I have as of now.
.search {
background:rgba(0,0,0,0.6);
border: 2px solid #414141;
border-radius: 5px;
padding: 10px;
}
header {
text-align: center;
color: #fff;
background-attachment: scroll;
background-image: url(../img/header-bg.jpg);
background-position: center center;
background-repeat: none;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
header .intro-text {
padding-top: 100px;
padding-bottom: 50px;
}
header .intro-text .intro-lead-in {
margin-bottom: 25px;
font-family: "Droid Serif","Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 22px;
font-style: italic;
line-height: 22px;
}
As for the HTML:
<body id="page-top" class="index">
<!-- I have a navbar here -->
<!-- Header -->
<header>
<div class="intro-text">
<div class="intro-lead-in">Welcome To Our Studio!</div>
<div class="intro-heading">It's Nice To Meet You</div>
</div>
</header>
</body>
this is a fiddle which containes the style of the bar. I think it may help you.Main interest css is:
.header-link {
float: left;
height: 60px;
margin: 0px 7px auto 0px;
}
.header-link a {
line-height: 62px;
color:#FFF;
}
.header-hiring-btn {
background-color: #CB202D;
padding: 7px 8px 6px;
border-radius: 3px;
text-align: center;
color: #FFF !important;
transition: all 0.15s ease-out 0s;
margin-right: 6px;
}
.header {
box-sizing: border-box;
height: 60px;
position: absolute;
width: 100%;
z-index: 7;
background: none repeat scroll 0% 0% rgba(45, 45, 45, 0.8) !important;
color:#FFF;
}
.wrapper {
padding-left: 10px;
padding-right: 10px;
margin-right: auto;
margin-left: auto;
box-sizing: border-box;
max-width: 1140px;
}
.col-s-16 {
width: 100%;
box-sizing: border-box;
}
.logo-header {
width: 134px;
}
.logo {
display: inline-block;
float: left;
text-align: center;
height:46px;
}
.logo img {
width: 130px;
margin-top: 15px;
margin-left: -4px;
vertical-align: middle;
border: 0px none;
}
.header-navigation {
float: right;
display: inline-block;
height: 60px;
}
.login-navigation {
float: left;
}
.header-link {
float: left;
height: 60px;
margin: 0px 7px auto 0px;
}
.header-link a {
line-height: 62px;
color:#FFF;
}
.header-hiring-btn {
background-color: #CB202D;
padding: 7px 8px 6px;
border-radius: 3px;
text-align: center;
color: #FFF !important;
transition: all 0.15s ease-out 0s;
margin-right: 6px;
}
<header class="header header--fixed " id="header">
<div class="wrapper">
<div class="">
<div class="col-s-16"> <a class="logo logo--header" href="https://www.zomato.com" title="">
<img src="https://bzmtcdn-a.akamaihd.net/images/logo/zlogo.png" alt="">
</a>
<section class="header-navigation" id="header-navigation">
<section class="login-navigation" id="login-navigation">
<div class="header-link"> <a class="header-hiring-btn" href="https://www.zomato.com/careers" target="_blank">We're Hiring!</a>
</div> <span class="header-link">
Log in with Facebook
</span>
<span class="header-link mr0">
Log in
</span>
</section>
</section>
<!-- end header-navigation -->
</div>
<!-- end col-s-16 -->
</div>
<!-- end row -->
</div>
<!-- end wrapping class -->
</header>
The code seems to be based on bootstrap.css rebuild. Hope it helps.

Resources