I am using the flexbox to center align the items inside (as nothing else seems to work). Although the bootstrap responsive-embed seems to completely disappear and i have no idea why. I can't not use position: relative on the embed as this stop it being responsive. Here is the code for it...
.embed-responsive {
/*position: initial;*/ /* if set to initial or anything other than relative is re-appears but is no longer responsive */
}
body {
background: grey;
}
div.title-area {
height: 350px;
width: 100%;
position: relative;
padding: 0 50px 0 50px;
}
div.title-area .video {
box-shadow: 0 5px 15px rgba(0, 0, 0, .3);
}
div.title-area > .col-md-6 {
min-height: 100%;
display: flex;
align-items: center;
}
div.title-area h1 {
text-shadow: 0 3px 6px rgba(0, 0, 0, .35);
margin: 0;
text-transform: uppercase;
/*vertical-align: middle;
display: table-cell;
position: relative;*/
}
.title-area h1 > small{
color: white;
font-size: 15px;
text-indent: 5px;
display: block;
opacity: .6;
text-transform: uppercase;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="title-area">
<div class="col-md-6">
<h1>main title<small>subtitle</small></h1>
</div>
<div class="col-md-6">
<div class="embed-responsive embed-responsive-16by9 video">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/rqEy5_W6YHQ?showinfo=0"></iframe>
</div>
</div>
</div>
JSFiddle
Taking a look to Grid system you may insert your "col-md-6" inside two rows like in the following snipppet:
body {
background: grey;
}
div.title-area {
height: 350px;
width: 100%;
position: relative;
padding: 0 50px 0 50px;
}
div.title-area .video {
box-shadow: 0 5px 15px rgba(0, 0, 0, .3);
}
div.title-area > .col-md-6 {
min-height: 100%;
display: flex;
align-items: center;
}
div.title-area h1 {
text-shadow: 0 3px 6px rgba(0, 0, 0, .35);
margin: 0;
text-transform: uppercase;
/*vertical-align: middle;
display: table-cell;
position: relative;*/
}
.title-area h1 > small{
color: gray;
font-size: 15px;
text-indent: 5px;
display: block;
opacity: .6;
text-transform: uppercase;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="title-area">
<div class="row">
<div class="col-xs-6">
<h1>main title<small>subtitle</small></h1>
</div>
<div class="col-xs-6">
<div class="embed-responsive embed-responsive-16by9 video">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/rqEy5_W6YHQ?showinfo=0"></iframe>
</div>
</div>
</div>
</div>
Add a div around the embed-responsive div so that the former can flow in the flex div and the latter can have position relative needed by the embed-responsive-item. Give the new div a flex-grow style of 1 so it sizes.
HTML:
<div class="title-area">
<div class="col-md-6">
<h1>main title<small>subtitle</small></h1>
</div>
<div class="col-md-6">
<div style="flex-grow: 1;">
<div class="embed-responsive embed-responsive-16by9 video">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/rqEy5_W6YHQ?showinfo=0"></iframe>
</div>
</div>
</div>
</div>
Styles:
.embed-responsive {
// position: initial;
/* if set to initial or anything other than relative is re-appears but is no longer responsive */
}
body {
background: grey;
}
div.title-area {
height: 350px;
width: 100%;
position: relative;
padding: 0 50px 0 50px;
}
div.title-area .video {
box-shadow: 0 5px 15px rgba(0, 0, 0, .3);
}
div.title-area > .col-md-6 {
min-height: 100%;
display: flex;
align-items: center;
}
div.title-area h1 {
text-shadow: 0 3px 6px rgba(0, 0, 0, .35);
margin: 0;
text-transform: uppercase;
/*vertical-align: middle;
display: table-cell;
position: relative;*/
}
.title-area h1 > small {
color: white;
font-size: 15px;
text-indent: 5px;
display: block;
opacity: .6;
text-transform: uppercase;
}
https://jsfiddle.net/rz5cmpz3/2/
Related
The issue is the header: I need it to seem to be fixed on the fixed section and still be clickable.
When the first section scrolls over the header, it should cover the header.
I can move or change the header however I want:
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
and while I could add the header to the invisible section, I cannot change the overall structure of the sections:
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
I tried adding the header to the invisible section and while this works in keeping the header clickable, I cannot make it seem to be fixed the same as the fixed section.
I realise describing it might be confusing so here are some accompanying images and please check the FIDDLE
#import url("https://fonts.googleapis.com/css2?family=Baloo+Da+2&display=swap");
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
html, body {
margin: 0;
padding: 0;
}
body {
font-size: 16px;
font-family: 'Baloo Da 2', cursive;
}
.header {
background: floralwhite;
display: inline-block;
padding: 10px;
position: fixed;
z-index: 3;
left: 30px;
top: 30px;
color: inherit;
text-decoration: none;
line-height: 1.2;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.5);
transition: all .5s ease;
}
.header:hover {
box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.5);
background-color: pink;
}
.wrapper {
border: 2px solid red;
z-index: 2;
position: relative;
}
.section {
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.section-fixed {
background: gray;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1;
}
.section-invisible {
align-items: flex-end;
padding: 0;
}
.section-invisible h2 {
background: goldenrod;
padding: 50px;
margin: 0;
width: 100%;
text-align: center;
}
.section-first {
background: darkslateblue;
color: white;
}
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
initial:
after scroll:
Update your z-index like below. The most important is to not set any z-index to wrapper:
#import url("https://fonts.googleapis.com/css2?family=Baloo+Da+2&display=swap");
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body {
margin: 0;
padding: 0;
}
body {
font-size: 16px;
font-family: 'Baloo Da 2', cursive;
}
.header {
background: floralwhite;
padding: 10px;
position: fixed;
z-index: 2; /* here */
left: 30px;
top: 30px;
color: inherit;
text-decoration: none;
line-height: 1.2;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.5);
transition: all .5s ease;
}
.header:hover {
box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.5);
background-color: pink;
}
.wrapper {
border: 2px solid red;
position: relative;
}
.section {
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.section-fixed {
background: gray;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1; /* here */
}
.section-invisible {
align-items: flex-end;
padding: 0;
position: relative;
z-index: 1; /* here */
}
.section-invisible h2 {
background: goldenrod;
padding: 50px;
margin: 0;
width: 100%;
text-align: center;
}
.section-first {
background: darkslateblue;
color: white;
position: relative;
z-index: 2; /* here */
}
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
Related: Why can't an element with a z-index value cover its child?
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>
I think I'm quite close to getting it right but the problem I'm having right now is that the texts overflow when the screen gets really small..which is unlikely to happen but I want to fix it so that the texts will never overflow out of the box.
How can I achieve that?
Here's my fiddle - https://jsfiddle.net/q3vue7wy/
.wrapper {
display: flex;
justify-content: center;
align-items: center;
font-size: 1rem;
height: 7.75rem;
transition: all 300ms;
box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
border: solid 1px #F5F5F5;
}
.imageContainer {
flex: 0 0 33%;
height: 100%;
}
.image {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
flex: 1;
text-align: left;
margin: 0 1.1825rem;
}
.title {
font-size: 1rem;
margin: 0 0 0.25rem 0;
padding: 0;
}
.price {
color: #BAA082;
font-size: 0.875rem;
text-transform: uppercase;
margin: 2rem 0 0;
padding: 0;
}
#media(min-width: 46.5rem) {
.wrapper {
height: 8.75rem;
}
.title {
font-size: 1.1875rem;
}
.price {
font-size: 1rem;
}
}
<div class="wrapper">
<div class="content">
<h4 class="title">Point of sale</h4>
<p>Point of sale</p>
<p class="price">From £165</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image"></div>
</div>
A simple solution is to make the image width shrink when the card gets too small. To do this, change the following properties:
.wrapper {
justify-content: space-between;
}
.imageContainer {
flex: 0 1 33%;
}
.content {
flex: 0 0 auto;
}
Which should give:
.wrapper {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1rem;
height: 7.75rem;
transition: all 300ms;
box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
border: solid 1px #F5F5F5;
}
.imageContainer {
flex: 0 1 33%;
height: 100%;
}
.image {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
flex: 0 0 auto;
text-align: left;
margin: 0 1.1825rem;
}
.title {
font-size: 1rem;
margin: 0 0 0.25rem 0;
padding: 0;
}
.price {
color: #BAA082;
font-size: 0.875rem;
text-transform: uppercase;
margin: 2rem 0 0;
padding: 0;
}
#media(min-width: 46.5rem) {
.wrapper {
height: 8.75rem;
}
.title {
font-size: 1.1875rem;
}
.price {
font-size: 1rem;
}
}
<div class="wrapper">
<div class="content">
<h4 class="title">Point of sale</h4>
<p>Point of sale</p>
<p class="price">From £165</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image"></div>
</div>
JSFiddle: https://jsfiddle.net/wq1cev3y/
HTML- Replace the below code to your HTML code
<div class="wrapper">
<div class="content">
<h4 class="title">
Point of sale
</h4>
<p class="dec">
Point of sale
</p>
<p class="price">
From £165
</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image">
</div>
</div>
CSS- Replace the below code to your media query code.
#media only screen and (max-width: 600px)
{
.wrapper{
height: 8.75rem;
}
.title{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
.dec{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
.price{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
}
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/
On my image I have a progress bar in svg that wraps around image. How ever when I try and center the image it does not go into the middle. The svg does but not the image.
Question: How is it possible to make the img and svg be in middle of column.
Codepen Example Here
HTML
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="column-module">
<div class="profile-module-info">
<div class="row">
<div class="col-lg-3">
<div class="profile-avatar">
<div class="image">
<img data-src="holder.js/154x154" width="154" height="154" class="img-circle img-thumbnail" />
</div>
<svg class="mi-progressbar">
<circle id="circle" r="25%" cx="50%" cy="50%" stroke-width="10"></circle>
</svg>
</div>
</div>
<div class="col-lg-6">
</div>
<div class="col-lg-3">
<div class="profile-statistics">
<ul class="list-unstyled">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
body {
background-color: #F0F0F0;
}
.container {
margin-top: 40px;
}
.column-module {
background: #fff none repeat scroll 0 0;
border-radius: 4px;
min-height: 100px;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.08), 0 2px 4px 0 rgba(0, 0, 0, 0.12);
margin-bottom: 20px;
}
.column-module .column-module-heading {
border-bottom: 1px solid #dedede;
padding: 20px;
}
.column-module .column-module-heading {
border-bottom: 1px solid #dedede;
padding: 20px;
}
.column-module .column-module-heading .column-module-title {
color: #1f2836;
font-size: 18px;
font-weight: bold;
}
.btn-group{
display: flex;
}
.profile-avatar {
border: 1px solid #bec0c2;
position: relative;
text-align: center;
margin-left: 2rem;
margin-top: -2rem;
margin-bottom: 2rem;
}
.profile-avatar svg {
position: relative;
transform: rotate(-90deg);
fill: none;
stroke: #337ab7;
stroke-dasharray: 0 0;
}
.profile-avatar img {
position: absolute;
top: 0;
left: 0;
text-align: center;
z-index: 1;
}
svg circle.progress-bar-success{
stroke:#5cb85c;
}
svg circle.progress-bar-info{
stroke:#5bc0de
}
svg circle.progress-bar-warning{
stroke:#f0ad4e;
}
svg circle.progress-bar-danger{
stroke:#d9534f;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
padding: 0;
}
a {
cursor: pointer;
}
Try this:
.profile-avatar img {
position: absolute;
margin: auto;
left: 0;
right: 0;
text-align: center;
z-index: 1;
}
Codepen Fork