Hi Stack Overflow Community,
Novice HTML user: I am currently using the Baguette gallery (v1.8.1) code for my gallery site.
Tutorial: http://yifangdi.blogspot.com/2017/05/baguetteboxjs-simple-and-easy-to-use.html
I want to change the font style of the "data-caption"
example code:
or implement a hover-over caption .css style rule.
CSS for gallery grid:
body {
background - image: linear - gradient(to top, #d3c081 % , #d3c081 75 % , #d3c081 100 % );
min - height: 100 vh;
font: normal 16 px sans - serif;
padding: 100 px 0;
}
.container.gallery - container {
background - color: #163049;
color: # 163049;
min - height: 100 vh;
border - radius: 20 px;
box - shadow: 0 8 px 15 px rgba(0, 0, 0, 0.06);
}
.gallery - container h1 {
text - align: center;
margin - top: 70 px;
font - family: 'Droid Sans', sans - serif;
font - weight: bold;
}
.gallery - container p.page - description {
text - align: center;
max - width: 800 px;
margin: 25 px auto;
color: #888;
font-size: 18px;
}
.tz-gallery {
padding: 40px;
}
.tz-gallery .lightbox img {
width: 100%;
margin-bottom: 30px;
transition: 0.2s ease-in-out;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}
.tz-gallery .lightbox img:hover {
transform: scale(1.05);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}
.tz-gallery img {
border-radius: 4px;
}
.baguetteBox-button {
background-color: transparent !important;
}
#media(max-width: 768px) {
body {
padding: 100px 0;
}
.container.gallery-container {
border-radius: 0;
}
}
<div class="container gallery-container">
<div class="tz-gallery">
<div class="row">
<div class="col-sm-6 col-md-4">
<a class="lightbox" href="images/park.jpg" data-caption="The Park">
<img src="images/park.jpg" alt="Park">
</a>
</div>
</div>
</div>
</div>
body {
background-image: linear-gradient(to top, #d3c081%, #d3c081 75%, #d3c081 100%);
min-height: 100vh;
font: normal 16px sans-serif;
padding: 100px 0;
}
.container.gallery-container {
background-color: #163049;
color: #163049;
min-height: 100vh;
border-radius: 20px;
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.06);
}
.gallery-container h1 {
text-align: center;
margin-top: 70px;
font-family: 'Droid Sans', sans-serif;
font-weight: bold;
}
.gallery-container p.page-description {
text-align: center;
max-width: 800px;
margin: 25px auto;
color: #888;
font-size: 18px;
}
.tz-gallery {
padding: 40px;
}
.tz-gallery .lightbox img {
width: 100%;
margin-bottom: 30px;
transition: 0.2s ease-in-out;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}
.tz-gallery .lightbox img:hover {
transform: scale(1.05);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}
.tz-gallery img {
border-radius: 4px;
}
.baguetteBox-button {
background-color: transparent !important;
}
#media(max-width: 768px) {
body {
padding: 100px 0;
}
.container.gallery-container {
border-radius: 0;
}
}
[data-caption="The Park"] {
font: italic 16px sans-serif;
font-size: 2em;
}
<div class="container gallery-container">
<div class="tz-gallery">
<div class="row">
<div class="col-sm-6 col-md-4">
<a class="lightbox" href="images/park.jpg" data-caption="The Park">
<img src="images/park.jpg" alt="Park">
</a>
</div>
</div>
</div>
</div>
use [data-caption] like below
[data-caption="The Park"] {
font: italic 16px sans-serif;
font-size: 2em;
}
So I've started using Material Kit UI and right now as you can see in the picture the image inside columns are different in height.
and also here is the code:
<div class="container-fluid sec1">
<div class="row">
<div class="col-sm-3 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/Ki247.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/Ki247.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
</div>
</div>
and the css:
.anime {
margin-bottom: 20px;
background: none !important;
box-shadow: none !important;
}
.card-blog {
margin-top: 30px;
}
.card {
display: inline-block;
position: relative;
width: 100%;
margin-bottom: 30px;
border-radius: 6px;
color: rgba(0,0,0, 0.87);
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.card .card-image {
height: 60%;
position: relative;
z-index: 1;
margin-left: 15px;
margin-right: 15px;
margin-top: -30px;
border-radius: 6px;
}
.animeimg {
margin-left: 0 !important;
margin-right: 0 !important;
}
.timenumber {
z-index: 9999;
font-size: 12px !important;
float: right;
position: absolute;
padding: 8px 10px;
color: #fff;
}
a {
text-decoration: none !important;
}
.card .card-image img {
width: 100%;
border-radius: 6px;
pointer-events: none;
box-shadow: 0 5px 15px -8px rgba(0, 0, 0, 0.24), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: auto;
}
.card .card-image .colored-shadow {
transform: scale(0.94);
top: 12px;
filter: blur(12px);
position: absolute;
width: 100%;
height: 100%;
background-size: cover;
z-index: -1;
transition: opacity .45s;
opacity: 0;
}
.ripple-container {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: inherit;
pointer-events: none;
}
.animeimg:after {
border-radius: 6px;
position: absolute;
z-index: 1;
width: 100%;
height: 98.5%;
display: block;
left: 0;
top: 0;
content: "";
background: -webkit-linear-gradient(top, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
}
.card .card-content {
padding: 15px 30px;
}
.sectit {
padding: 0 !important;
}
.sectit > h6 {
padding-bottom: 10px;
font-size: 12px;
display: none;
}
.text-success {
color: #4caf50;
}
.text-success {
color: #3c763d;
}
.card-blog .card-title {
margin-top: 5px;
}
#media (min-width: 992px)
.sectit > h4 {
width: 60%;
}
.sectit > h4 {
margin-top: 5px !important;
margin-bottom: 5px;
width: 65%;
direction: ltr;
float: left;
font-weight: 700;
font-size: .9rem;
font-family: 'Roboto Condensed';
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.title, .title a, .card-title, .card-title a, .info-title, .info-title a, .footer-brand, .footer-brand a, .footer-big h5, .footer-big h5 a, .footer-big h4, .footer-big h4 a, .media .media-heading, .media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.title, .card-title, .info-title, .footer-brand, .footer-big h5, .footer-big h4, .media .media-heading {
font-weight: 700;
font-family: "Roboto Slab", "Times New Roman", serif;
}
.sectit > h4 > a {
color: #000;
}
.title, .title a, .card-title, .card-title a, .info-title, .info-title a, .footer-brand, .footer-brand a, .footer-big h5, .footer-big h5 a, .footer-big h4, .footer-big h4 a, .media .media-heading, .media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.card .footer {
margin-top: 15px;
}
.episodenumber {
float: right;
margin-top: 8px !important;
font-size: 12px;
}
so I've tried to change height in ".card img" (from auto to 18rem) but the images wasn't responsive anymore.
I also tried to set min-height but it didn't work too.
here two image with different height:
- https://i.stack.imgur.com/Ki247.jpg
- https://i.stack.imgur.com/vGjYd.jpg
You will need set the height of .card .card-image a and then overflow:hidden to hide the extra content.
.card .card-image a {
display: block;
height: 300px;
overflow: hidden;
border-radius: 10px;
}
Stack Snippet
.anime {
margin-bottom: 20px;
background: none !important;
box-shadow: none !important;
}
.card-blog {
margin-top: 30px;
}
.card {
display: inline-block;
position: relative;
width: 100%;
margin-bottom: 30px;
border-radius: 6px;
color: rgba(0, 0, 0, 0.87);
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.card .card-image {
height: 60%;
position: relative;
z-index: 1;
margin-left: 15px;
margin-right: 15px;
margin-top: -30px;
border-radius: 6px;
}
.animeimg {
margin-left: 0 !important;
margin-right: 0 !important;
}
.timenumber {
z-index: 9999;
font-size: 12px !important;
float: right;
position: absolute;
padding: 8px 10px;
color: #fff;
}
a {
text-decoration: none !important;
}
.card .card-image img {
width: 100%;
border-radius: 6px;
pointer-events: none;
box-shadow: 0 5px 15px -8px rgba(0, 0, 0, 0.24), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: auto;
}
.card .card-image .colored-shadow {
transform: scale(0.94);
top: 12px;
filter: blur(12px);
position: absolute;
width: 100%;
height: 100%;
background-size: cover;
z-index: -1;
transition: opacity .45s;
opacity: 0;
}
.ripple-container {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: inherit;
pointer-events: none;
}
.animeimg:after {
border-radius: 6px;
position: absolute;
z-index: 1;
width: 100%;
height: 98.5%;
display: block;
left: 0;
top: 0;
content: "";
background: -webkit-linear-gradient(top, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, .5) 100%);
}
.card .card-content {
padding: 15px 30px;
}
.sectit {
padding: 0 !important;
}
.sectit>h6 {
padding-bottom: 10px;
font-size: 12px;
display: none;
}
.text-success {
color: #4caf50;
}
.text-success {
color: #3c763d;
}
.card-blog .card-title {
margin-top: 5px;
}
#media (min-width: 992px) .sectit>h4 {
width: 60%;
}
.sectit>h4 {
margin-top: 5px !important;
margin-bottom: 5px;
width: 65%;
direction: ltr;
float: left;
font-weight: 700;
font-size: .9rem;
font-family: 'Roboto Condensed';
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.title,
.title a,
.card-title,
.card-title a,
.info-title,
.info-title a,
.footer-brand,
.footer-brand a,
.footer-big h5,
.footer-big h5 a,
.footer-big h4,
.footer-big h4 a,
.media .media-heading,
.media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.title,
.card-title,
.info-title,
.footer-brand,
.footer-big h5,
.footer-big h4,
.media .media-heading {
font-weight: 700;
font-family: "Roboto Slab", "Times New Roman", serif;
}
.sectit>h4>a {
color: #000;
}
.title,
.title a,
.card-title,
.card-title a,
.info-title,
.info-title a,
.footer-brand,
.footer-brand a,
.footer-big h5,
.footer-big h5 a,
.footer-big h4,
.footer-big h4 a,
.media .media-heading,
.media .media-heading a {
color: #3C4858;
text-decoration: none;
}
.card .footer {
margin-top: 15px;
}
.episodenumber {
float: right;
margin-top: 8px !important;
font-size: 12px;
}
.card .card-image a {
display: block;
height: 300px;
overflow: hidden;
border-radius: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid sec1">
<div class="row">
<div class="col-xs-6 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/Ki247.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/Ki247.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-2 col-lg-2">
<div class="anime card card-blog">
<div class="card-image animeimg">
<div class="timenumber">
<h4>2 دقیقه قبل</h4>
</div>
<a href="#" title="Sword Art Online">
<img class="img" src="https://i.stack.imgur.com/vGjYd.jpg">
</a>
<div class="colored-shadow" style="background-image: url("https://i.stack.imgur.com/vGjYd.jpg"); opacity: 1;"></div>
<div class="ripple-container"></div>
</div>
<div class="card-content sectit">
<h6 class="category text-success">در حال پخش</h6>
<h4 class="card-title">
Sword Art Online
</h4>
<div class="footer episodenumber">
قسمت 13
</div>
</div>
</div>
</div>
</div>
</div>
I am building a responsive form design for desktop and mobile devices.
I write a following code for that and it is working fine but it generates the problem when i resize window like mobile screen width the left and right margin space is little large. I want to minimize the space of left and right margin i tried a lot but fail can some one help me please
.main_container {
position: relative;
width: 100%;
border-top: 2px solid #e4e4e4;
border-bottom: 2px solid #e4e4e4;
overflow: hidden;
}
.main_container:after {
width: 0;
height: 0;
border-style: solid;
border-width: 100px 100px 0 100px;
border-color: #007bff transparent transparent transparent;
}
.left_parent {
float: left;
}
.left_child {
padding-right: 2%;
padding-left: 0%;
text-align: center;
}
.right_child {
padding-right: 0%;
padding-left: 0%;
text-align: center;
/*width: 40%;*/
}
.right_parent {
float: left;
}
.left_uppper_text {
font-family: 'Open Sans', sans-serif;
font-size: 130%;
text-align: justify;
margin-right: 3%;
color: #847979;
}
.left_bottom_text {
font-family: 'Open Sans', sans-serif;
font-size: 81%;
color: #bbb;
font-weight: bold;
}
.main_child {
margin: auto;
padding: 0% 0% 0% 27%;
overflow: hidden;
margin: auto;
width: 50%;
/* border: 3px solid green; */
padding: 10px;
}
.input_email {
width: 67%;
padding: 3% 17px;
box-sizing: border-box;
margin: 8px 0;
}
.input_button {
max-width: 190px;
min-width: 84px;
padding: 3% 20px;
box-sizing: border-box;
margin: 8px 0;
background-color: rgba(245, 0, 83, 0.73);
color: white;
border: none;
border-top: 2px solid rgba(245, 0, 83, 0.73);
border-bottom: 2px solid rgba(245, 0, 83, 0.73);
}
<div class="main_container">
<div class="main_child">
<div class="left_parent">
<div class="left_child">
<span class="left_uppper_text"> Join over 20,2000 blog subscriber </span> <br>
<span class="left_bottom_text"> We guarantee 100% customer satisfaction</span>
</div>
</div>
<div class="right_parent">
<div class="right_child">
<input type="text" class="input_email">
<button class="input_button">Subscribe</button>
</div>
</div>
</div>
</div>
So, you can manipulate styles at any screen size using #media queries. In your case it might look something like this:
#media (max-width: 768px /* Mobile size */) {
/* Element you want to style at this screen size */
.element {
margin: 5px; /* Or whatever style you want */
}
}
You can read more about #media queries here: https://www.w3schools.com/cssref/css3_pr_mediaquery.asp
I am trying to work on the following example for a user profile.
I have a problem with the text on my various fields though. I would like them to be centered horizontally and vertically.
Using
vertical-align: middle;
Did not work for me, or I did something wrong.
How can I make it so each text snippet is perfectly centered on its respective container?
Here's the solution:
/* --------------------------------
Primary style
-------------------------------- */
#font-face {
font-family: 'Roboto';
src: url('../fonts/roboto/Roboto-Regular.ttf');
font-weight: normal;
font-style: normal;
}
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
div {
display: block;
}
html,
body {
background: #f1f1f1;
font-family: 'Roboto', sans-serif;
padding: 1em;
}
h1 {
text-align: center;
color: #a8a8a8;
font-size: 200%;
}
.user-data {
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
position: relative;
overflow: hidden;
cursor: pointer;
display: table;
width: 100%;
height: 85px;
background: white;
margin: 0 auto;
margin-top: 1em;
margin-bottom: 20px;
border-radius: 8px;
-webkit-transition: all 250ms;
transition: all 250ms;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
.response-layer {
vertical-align: middle;
display: table-cell;
text-align: center;
font-size: 200%;
color: #a8a8a8;
}
#user-action-text {
color: #f1f1f1;
font-size: 400%;
}
#user-name {
border: 0;
outline: 0;
padding: 0;
margin: 0px;
margin-top: 10px;
width: 304px;
height: 55px;
color: white;
}
#user-action {
background: #e74c3c;
height: 134px;
}
#user-position {
height: 74px;
}
#user-uuid {
height: 54px;
}
section {
max-width: 650px;
text-align: center;
margin: 20px auto;
}
section img {
border: 0;
outline: 0;
padding: 0;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
display: block;
width: 100%;
margin-top: 1em;
-webkit-transition: all 250ms;
transition: all 250ms;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
resize: none;
}
.half {
float: left;
width: 48%;
margin-bottom: 1em;
}
.right {
width: 50%;
}
.left {
margin-right: 2%;
}
.user-data:hover {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
-webkit-transform: translateY(-5px);
-ms-transform: translateY(-5px);
transform: translateY(-5px);
}
section img:hover {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
-webkit-transform: translateY(-5px);
-ms-transform: translateY(-5px);
transform: translateY(-5px);
}
#-webkit-keyframes loading {
0%, 100% {
margin-top: -50px;
box-shadow: 0px 55px 40px 0px rgba(0, 0, 0, 0.3);
}
30%,
80% {
margin-top: 0px;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5);
}
}
#keyframes loading {
0%, 100% {
margin-top: -50px;
box-shadow: 0px 55px 40px 0px rgba(0, 0, 0, 0.3);
}
30%,
80% {
margin-top: 0px;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5);
}
}
#media (max-width: 690px) {
.half {
width: 304px;
float: none;
margin-bottom: 0;
}
}
/* Clearfix */
.activity-detail:before,
.activity-detail:after {
content: " ";
/* 1 */
display: table;
/* 2 */
}
.activity-detail:after {
clear: both;
}
<h1>New Activity Details</h1>
<section class="activity-detail">
<div class="half right" id="image-data">
<img src="img/default-avatar.png" alt="Profile Photo" style="width:304px;height:304px;" id="profile-photo">
<a class="user-data" id="user-name">
<div class="response-layer">Green Leaf</div>
</a>
</div>
<div class="half left" id="general-data">
<a class="user-data" id="user-action">
<div class="response-layer" id="user-action-text">Greetings</div>
</a>
<a class="user-data" id="user-position">
<div class="response-layer">Developer</div>
</a>
<a class="user-data" id="user-uuid">
<div class="response-layer">324124535345</div>
</a>
</div>
</section>
On the parent div .user-data I changed display to table.
On the child div .response-layer (the one containing "Greetings") I changed the display to table-cell. Now the vertical align works.
Here's the link to the codepen: Codepen
Replacing
vertical-align: middle;
with
position: relative;
top: 25%;
does the trick.
Edit: The answer above is much cleaner
I cannot seem to get this number to align inline to the glyphicon. I want the number 3 to be pushed up more so that it lines up.
CSS
body {
background-image: url("bg1.png");
}
.icons {
margin: 0px 0px 0px 10px;
}
.well {
min-height: 20px;
padding: 20px;
margin-bottom: 20px;
background-color: #ecf0f1;
border: 1px solid transparent;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.well blockquote {
border-color: #ddd;
border-color: rgba(0, 0, 0, 0.15);
}
.well-lg {
padding: 10px;
border-radius: 6px;
}
.well-sm {
padding: 9px;
border-radius: 3px;
}
#alertbox {
padding: 2px 2px 2px 2px;
text-align: center;
}
#topicon {
font-size: 50px;
}
#stats {
font-size: 50px;
display: inline-block;
float: right;
}
HTML
<div class="col-md-3">
<div class="well well-lg">
<div id="alertbox" class="alert alert-info">Total APIs</div>
<span id="topicon" class="glyphicon glyphicon-tasks"></span>
<span id="stats">3</span>
</div>
</div>
Screenshot
using the positioning doesnt work when scaling since the number 3 would go into the center when on a mobile phone. I need it to auto-scale i guess for smaller browsers.
If you remove the float from #stats, you could do something like this:
.well {text-align: justify;}
.well:after{content:""; width: 100%; display: inline-block; height: 0;}
span {display: inline-block; vertical-align: middle;}