Avoiding an image hover content from resizing on windows resize - html

hello guys I am designing a website which consist of an image and a hover effect which fades out a text. it is pretty working fine but it became a mess when i resized the browser window, the image is still positioned but the hover content resizes i just want it to be the same size with the image on resize.
Any way out of this mess, any answer is appreciated thanks.
figure {
overflow: hidden;
margin: 0;
padding: 0;
}
figure:hover img {
transition-duration: 0.8s;
}
figure figcaption {
position: absolute;
top: 0;
left: 20px;
width: 90% !important;
height: 95%;
opacity: 0;
transition-duration: 0.8s;
color: #000;
}
figure:hover figcaption {
opacity: 1;
}
.styleme {
background: #fff;
font-family: playball;
margin-top: 36%;
height: 80px;
}
<div class="row">
<div class="col-lg-6 col-md-4 col-sm-6 col-xs-12">
<div class="thumbnail">
<figure>
<img class="img-responsive" src="macbookair11_lifestyle_20.jpg" />
<figcaption>
<div class="styleme">
<p>This is the Apple macbook and it is pro <i class="fa fa-apple"></i> justclick to purchase</p>
<p>Proccessor: works at 3.14Ghz</p>
<p>Internal Ram: It has a Ram of 8GB <i class="fa fa-bars" aria-hidden="true"></i></p>
</div>
</figcaption>
</figure>
</div>
</div>
</div>

Evidently, your image must be very large if you want it to fill most of the page. I have used a small image and sized appropriately for demo purposes.
The key difference I made was to use display:block and position:relative.
It's good to minimise the use of absolute positioning where possible. (That's why I adjusted the top and left to margin-top and margin-left)
Adjust the numbers in the css as you see appropriate
Hope this helps
figure {
overflow: hidden;
margin: 0;
padding: 0;
}
figure:hover img {
transition-duration: 0.8s;
}
figure figcaption {
display:block;
position: relative;
margin-top: 0;
margin-left: 20px;
width: 400px !important;
height: 450px;
opacity: 0;
transition-duration: 0.8s;
color: #000;
}
figure:hover figcaption {
opacity: 1;
}
.styleme {
background: #fff;
font-family: playball;
margin-top: 10%;
height: 80px;
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-lg-6 col-md-4 col-sm-6 col-xs-12">
<div class="thumbnail">
<figure>
<img class="img-responsive" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSs87UCUOVgNUoz7-AlLppXgeDyC1DnITzZjk6xMJN4P94oMps1" />
<figcaption>
<div class="styleme">
<p>This is the Apple macbook and it is pro <i class="fa fa-apple"></i> justclick to purchase</p>
<p>Proccessor: works at 3.14Ghz</p>
<p>Internal Ram: It has a Ram of 8GB <i class="fa fa-bars" aria-hidden="true"></i></p>
</div>
</figcaption>
</figure>
</div>
</div>
</div>
EDIT: (snippet 2 with larger image)
*{margin:0; padding:0;}
.thumbnail{
background: #fff;
}
figure img{
width:90%!important;
height: auto;
overflow: hidden;
margin: 0 auto;
}
figure:hover img {
transition-duration: 0.8s;
}
figure figcaption{
display:block;
position: relative;
opacity: 0;
transition-duration: 0.8s;
color: #000;
}
figure:hover figcaption {
opacity: 1;
}
.styleme {
background: #fff;
font-family: playball;
padding-top: 5%;
padding-left: 20px;
width:90%;
height:10%;
}
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-lg-6 col-md-4 col-sm-6 col-xs-12">
<div class="thumbnail">
<figure>
<img class="img-responsive" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQmGtZotDeGTAe1MOM1QZ-g6HfFnBCE3ASqsoUcSmfcMgHLPSOMyw" />
<figcaption>
<div class="styleme">
<p>This is the Apple macbook and it is pro <i class="fa fa-apple"></i> just click to purchase</p>
<p>Processor: works at 3.14Ghz</p>
<p>Internal Ram: It has a Ram of 8GB <i class="fa fa-bars" aria-hidden="true"></i></p>
</div>
</figcaption>
</figure>
</div>
</div>
</div>
https://jsfiddle.net/RachGal/4yqLeey9/

Related

Centre Image and Div Underlay in Bootstrap 4

I'm attempting to centre an image and div layer inside a containing div, but so far I can't get it to move from the left of the column. I've tried a few different ways but just can't get it to move. Even the margin auto trick isn't working, which I suspect is because bootstrap 4 is a flex box now.
HTML:
#user-avatar {
background: #ff4e00;
border-radius: 50%;
width: 250px;
margin-bottom: 25px;
position: relative;
}
#user img {
border-radius: 50%;
width: 250px;
transition: .5s ease;
backface-visibility: hidden;
}
#user-avatar:hover img {
cursor: pointer;
opacity: 0.3;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.middle i {
font-size: 34px;
}
#user-avatar:hover .middle {
opacity: 1;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<div id="user" class="col-12">
<div class="col-12" id="user-avatar">
<img class="mx-auto d-block" src="assets/users/av-lg/liane.png" />
<div class="middle">
<i class="fas fa-camera-alt"></i>
<p>Edit Avatar</p>
</div>
</div>
<p id="username" class="text-center"><span>Howdy </span>Liane</p>
<div id="xp-bar" class="text-left">
<div id="xp"><p><i class="fas fa-stars"></i> XP</p></div>
</div>
<p id="stats" class="text-right">Level 1</p>
</div>
It's the image and the 'underlay' ('middle' div) that I need to be in the center.
Add margin-left: 50% and transform: translateX(-50%) to #user-avatar. check below link.
thank you
http://jsfiddle.net/x1hphsvb/10994/
Add Class on id="user-avatar" to mx-auto
<div class="col-12 mx-auto" id="user-avatar">
<img class="d-block" src="assets/users/av-lg/liane.png" />
<div class="middle">
<i class="fas fa-camera-alt"></i>
<p>Edit Avatar</p>
</div>
</div>
https://jsfiddle.net/lalji1051/v06j8orn/9/
simply add this style - centrd now
#user-avatar {
margin: 0 auto;
}

Hover effect on image with text

I don't know how to make text in the photo, and make a link in the whole photo. I've made a darkening effect which I don't want to change, I just want to add text to it. I really want to keep the current dimensions and, above all, responsiveness.
There is link to codepen: 'https://codepen.io/pawe-dejda/pen/XyPzpK'
body, html {
height: 100%;
}
.caption {
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
color: #000;
}
.responsive {
width: 100%;
max-width: 88px;
height: auto;
position: center;
}
.tz-gallery .row > div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
#media(max-width: 768px) {
body {
padding: 0;
}
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/3/w3.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="http://dejda.e-kei.pl/nuar/css/style.css">
<div class="w3-container w3-padding-64 w3-black">
<div class="w3-content">
<div class="tz-gallery">
<div class="row no-gutters">
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
</div>
</div>
</div>
</div>
If i understand correctly, you want to be able to post links (link can be a-href, h1, h2, span etc') on top of your picture. To do so, do the following:
1. write a container div. for example:
<div>
text
</div>
set its style (CSS) to the background picture you want. Make sure the div's sizes fit the picture size. Then, inside the div you can simply write down the tag you wish (text). for example:
< span >
text
< /span >
Now things get interesting. In order to position the text inside the div? => set the div's position to relative (position:relative;) and set the span position to absolute. then play around with the top / left / bottom / right of the absoloute position, and text would appear whereever you want it to.
Here's an updated codepen
https://codepen.io/kelvinsusername/pen/YROYZM
It adds a container with some text in it but makes it opaque, then on hover instead of making it less visible (like the image) it makes it more visible.
.fade:hover .description {
opacity: 1;
}
.description {
position: absolute;
z-index: 100;
opacity: 0;
color: #fff;
font-size: 20px;
}
.tz-gallery .row>div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
.img-text-box {
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.479);
color: #ffffff;
width: 100%;
padding: 20px;
font-family: Arial;
font-size: 17px;
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
color: #e9e9e9;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="tz-gallery">
<div class="container">
<div class="row">
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Be brave js is cool</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Readability counts.</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>If the implementation is hard to explain, it's a bad idea.</p>
</div>
</a>
</div>
</div>
</div>
</div>

Padding on a Bootstrap 3 col seems impossible to remove

I am having some big problems with padding. Before the description of my problem make sense, there is 2 pages to see in the inspector window - and look in the mobile view device section:
1: This demopage is working as it should.
2: This demopage is not working.
The difference between the 2 pages is that I added one more row with three pictures in it. The row with 3 pictures is basic builded up like this:
<div class="row wrapping">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-8 margin_bottom">
<!-- Picture 1 -->
</div>
<div class="col-sm-4">
<div class="row">
<div class="col-sm-12 margin_bottom">
<!-- Picture 2 -->
</div>
</div>
<div class="row">
<div class="col-sm-12 margin_bottom">
<!-- Picture 3 -->
</div>
</div>
</div>
</div>
</div>
</div>
As I see it there is set a padding on the inner columns col > row > col? How can I remove that padding? I removed the padding on the rows with the below code, and thought that would also count for all columns.
.row.wrapping {
margin-right: 0;
margin-left: 0;
}
.wrapping > [class^="col-"], .wrapping > [class^=" col-"] {
padding-right: 0;
padding-left: 0;
}
The most important thing is that I cannot start overwriting Bootstrap classes since the whole site is building up with bootstrap. So every change I am overwriting in the bootstrap framework has to be named unique.
#front .row {
padding-bottom: 0px!important;
}
body {
background-color: #f5f5f5;
}
/* Removes default right padding */
.row.wrapping {
margin-right: 0;
margin-left: 0;
}
.wrapping>[class^="col-"],
.wrapping>[class^=" col-"] {
padding-right: 0;
padding-left: 0;
}
/* Set width between grid elements */
.small-padding.top {
padding-top: 10px;
}
.small-padding.bottom {
padding-bottom: 10px;
}
.small-padding.left {
padding-left: 5px;
}
.small-padding.right {
padding-right: 5px;
}
.margin_bottom {
margin-bottom: 10px;
}
.img-responsive {
height: 100%;
}
/* Position of buttons/text in a single grid element */
.inner-wrapper {
background: none;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.bottom-right {
position: absolute;
bottom: 8px;
right: 16px;
}
.bottom-left {
position: absolute;
bottom: 2%;
left: 6%;
}
/* Position text on full width banner */
.header-container {
color: white;
margin: 0 5%;
}
.banner-text {
position: absolute;
bottom: 3%;
left: 1%;
width: 80%;
}
/* Color on text */
.dark-font {
color: #333;
}
.light-font {
color: #fff;
text-transform: uppercase;
}
.blue-font {
color: #00a9ff;
text-transform: uppercase;
margin-top: -10px;
}
/* Set full width on columns */
#media (max-width: 768px) {
.img-responsive {
width: 100%;
height: auto;
}
/* btn-success: */
.btn-success {
width: fit-content;
}
}
#media (max-width: 991px) {
h3 {
font-size: 1.2em;
}
}
/* Hover for grid elements that contains text */
.hovereffect {
display: inline-block;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
transition: all 0.4s ease-in-out;
}
.hovereffect:hover .overlay {
background-color: rgba(170, 170, 170, 0.4);
}
.hovereffect h2,
.hovereffect img {
transition: all 0.4s ease-in-out;
}
.hovereffect img {
display: block;
position: relative;
transform: scale(1.1);
}
.hovereffect:hover img {
transform: scale(1);
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: rgba(0, 0, 0, 0.6);
}
.hovereffect p.info {
text-decoration: none;
color: #fff;
border: 1px solid #fff;
background-color: transparent;
opacity: 0;
transform: scale(1.5);
transition: all 0.4s ease-in-out;
font-weight: normal;
height: 90%;
width: 90%;
top: 5%;
/* (100% - 85%)/2 */
left: 5%;
position: absolute;
text-align: left;
padding: 20px 20px 20px 20px;
}
.hovereffect:hover p.info {
opacity: 1;
transform: scale(1);
background-color: rgba(0, 0, 0, 0.4);
}
/* Hover fadeout head and subline */
.hovereffect:hover .inner-wrapper.bottom-left h3,
.hovereffect:hover .inner-wrapper.bottom-left span {
transition: all 0.4s ease-in-out;
}
.hovereffect:hover .inner-wrapper.bottom-left h3,
.hovereffect:hover .inner-wrapper.bottom-left span {
opacity: 0;
}
/* Hover opacity for grid elements without text*/
.column {
padding: 0;
}
.column:last-child {
padding-bottom: 60px;
}
.column::after {
content: '';
clear: both;
display: block;
}
.column div {
position: relative;
float: left;
width: 300px;
height: 200px;
margin: 0 0 0 25px;
padding: 0;
}
.column div:first-child {
margin-left: 0;
}
figure {
margin: 0;
padding: 0;
background: #fff;
}
figure:hover+span {
bottom: -36px;
opacity: 1;
}
/* Opacity #1 */
.hover11 figure img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: 0.8s ease-in-out;
}
.hover11 figure:hover img {
opacity: .5;
}
<div class="wrapper">
<div class="row wrapping">
<div class="col-xs-12 col-sm-12 margin_bottom">
<!--<div class="hover11 column">-->
<a href="#">
<picture>
<source media="(min-width: 650px)" srcset="https://mimsi.dk/Static/Cms/d211428c-7ea9-4805-8b66-ee73d7f1df2d.jpg"></source>
<source media="(min-width: 320px)" srcset="https://mimsi.dk/Static/Cms/b1cbb0f1-9e91-4d55-8a8e-65631432c38b.jpg"></source>
<img src="http://mimsi.dk/Static/Cms/d211428c-7ea9-4805-8b66-ee73d7f1df2d.jpg" alt="mimsi Partnerværksteder" style="width:100%;"></img>
</picture>
<div class="inner-wrapper banner-text">
<div class="header-container">
<h2 class="blue-font" style="text-shadow: 2px 2px #000000;">Find nærmeste mimsi </h2>
<p class="light-font" style="text-shadow: 2px 2px #000000;">#</p>
<!--<span class="btn btn-primary" role="button">Lorem Ipsum</span>-->
</div>
</div>
</a>
<!--</div>-->
</div>
</div>
<!-- DELETE THIS ROW IN THE INSPECT WINDOW -->
<div class="row wrapping">
<div class="col-sm-12">
<div class="row">
<a href="/da-dk/page/bmw-packages/">
<div class="col-sm-8 margin_bottom">
<div class="hover11 column">
<figure>
<picture>
<source media="(min-width: 650px)" srcset="https://mimsi.dk/Static/Cms/f30dfbf6-047a-4aa4-829f-48d4223d05be.jpg"></source>
<source media="(min-width: 320px)" srcset="https://mimsi.dk/Static/Cms/ce50c03a-0e95-4760-95a4-e2ad2a1b6e43.jpg"></source>
<img src="https://mimsi.dk/Static/Cms/f30dfbf6-047a-4aa4-829f-48d4223d05be.jpg" alt="Lorem Ipsum" style="width:100%;"></img>
</picture>
</figure>
</div>
<div class="inner-wrapper bottom-left">
<h3 class="light-font" style="color:#333">Lorem Ipsum</h3>
<span class="light-font" style="color:#00a9ff">Lorem Ipsum</span>
<!--<button class="btn btn-success btn-lg">Læs mere</button>-->
</div>
</div>
</a>
<div class="col-sm-4">
<div class="row">
<a href="#">
<div class="col-sm-12 margin_bottom">
<div class="hover11 column">
<figure>
<img src="https://mimsi.dk/Static/Cms/7da4b142-e174-4dd4-aa44-cb175c1f92f0.jpg" alt="mimsi Lorem Ipsum" class="img-responsive"></img>
</figure>
</div>
<div class="inner-wrapper bottom-left">
<h4 class="light-font" style="color:#00a9ff">Vi er eneforhandler I Danmark</h4>
<span class="light-font">Lorem Ipsum</span>
<!--<button class="btn btn-success btn-lg">Læs mere</button>-->
</div>
</div>
</a>
</div>
<div class="row">
<a href="#">
<div class="col-sm-12 margin_bottom">
<div class="hover11 column">
<figure>
<a href="#" data-toggle="modal" data-target="#nyhedsbrev-tilmelding">
<img src="https://mimsi.dk/Static/Cms/d065fdf8-a5b1-4137-ba54-74c351185d36.jpg" alt="Signup newsletter" class="img-responsive"></img>
</a>
</figure>
</div>
<div class="modal fade" id="nyhedsbrev-tilmelding" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div id="mc_embed_signup">
</div>
</div>
</div>
</div>
</div>
<div class="inner-wrapper bottom-left"></div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
I'm not sure what you want to achieve, but for me, if you make a very little change at page https://koed.dk/da-dk/page/stack like below, then effect is great:
.row.wrapping,
.row.wrapping .row {
margin-left: -5px;
margin-right: -5px;
}
.wrapping [class^=col-] {
padding-left: 5px;
padding-right: 5px;
}
Brother in your styles you have this code .
.margin_bottom {
margin-bottom: 10px;
}
Remove it. That'll solve your problem.
One solution to your problem is that make a new css class no-padding like this
.no-padding{
padding-right: 0!important;
padding-left: 0!important;
}
And then add the no-padding class to your html row or col for which you want to remove padding like this.
<div class="row wrapping">
<div class="col-sm-12 no-padding"> <!-- notice here -->
<div class="row">
<div class="col-sm-8 margin_bottom no-padding"><!-- notice here -->
<!-- Picture 1 -->
</div>
<div class="col-sm-4 no-padding"><!-- notice here -->
<div class="row">
<div class="col-sm-12 margin_bottom no-padding"><!-- notice here -->
<!-- Picture 2 -->
</div>
</div>
<div class="row">
<div class="col-sm-12 margin_bottom no-padding"><!-- notice here -->
<!-- Picture 3 -->
</div>
</div>
</div>
</div>
</div>
</div>
In this way you won't have to override the bootstrap classes and you won't break the layout.

col-xs not working for media screen less than 768px

body {
margin-left: 50px !important;
margin-right: 50px !important;
}
.section {
background: rgba(255, 255, 255, 0.69);
height: 200px;
border: 1px solid #000;
}
.outer {
display: table;
width: 100%;
height: 100vh;
}
.inner {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.parent-div {
margin: 0 auto;
width: 82%;
}
.table-parent {
display: table;
}
.table-child {
display: table-cell;
vertical-align: middle;
}
.section:hover {
color: #ececeb;
transition: all 0.3s;
cursor: pointer;
}
.table-child .fa {
padding-right: 6px !important;
}
.section:hover .item-overlay.bottom {
bottom: 0;
}
.item-overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
overflow: hidden;
width: 100%;
-moz-transition: top 0.3s, right 0.3s, bottom 0.3s, left 0.3s;
-webkit-transition: top 0.3s, right 0.3s, bottom 0.3s, left 0.3s;
transition: top 0.3s, right 0.3s, bottom 0.3s, left 0.3s;
}
.item-overlay.bottom {
bottom: 100%;
}
.table-child p {
display: inline-block;
text-rendering: auto;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
a {
text-decoration: none;
color: #333 !important;
}
#AddProduct {
display: inline-block;
}
#media screen and (max-width: 767px) {
.col-xs-12 {
width: 100% !important;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<body>
<div class="row outer">
<div class="row inner">
<div class="clearfix parent-div">
<a data-toggle="modal" data-target="#myModal">
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-plus-circle" aria-hidden="true"></i>
<p>ADD A PRODUCT</p>
</h4>
</div>
</a>
<a>
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-pencil" aria-hidden="true"></i>
<p>EDIT A PRODUCT</p>
</h4>
</div>
</a>
<a data-toggle="modal" data-target="#removeModal">
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-minus-circle" aria-hidden="true"></i>
<p>REMOVE A PRODUCT</p>
</h4>
</div>
</a>
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-bars" aria-hidden="true"></i>
<p>USER'S LIST</p>
</h4>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-sort" aria-hidden="true"></i>
<p>ORDERS</p>
</h4>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 section table-parent">
<div class="item-overlay bottom"></div>
<h4 class="table-child"><i class="fa fa-power-off" aria-hidden="true"></i>
<p>LOGOUT</p>
</h4>
</div>
</div>
</div>
</div>
</body>
I am using Bootstrap v3. The divs are not taking 100% width in mobile devices with col-xs-12. Code is working fine for medium and small screens but retaining the 50% width for screens less than 768. Here is the link to the screenshot of the behaviour.
Image
Gone through all other available solutions but none worked for me.
I don't know how to put this into words but I am getting the desired output on resizing the browser window but the code doesn't seem to work on the actual device and the web inspector. Screenshot of the device Image
Additionally I tried with !important as well at the end of css but facing the same problem.
Taken from comment of chetan kalra and posting answer for quick reference for others. I also faced this issue and found viewport meta tag was missing. Adding below line did the trick.
<meta name="viewport" content="width=device-width, initial-scale=1.0">

I want to merge two cells together in the proposed html layout

I'm using this layout and as you can see there is a section with 8 pictures on the bottom of the page - each of them is a hyperlink to the bigger image. It works pretty neat, esp. when you resize the page to smaller size, then the 4 cells becomes 2 and it looks like this. I want to change it a little, so that two first pictures are merged together, so the layout could look like this, and when the user resizes it, it would show him a proper layout like this. So far the html code for that specific part of the page looks like this:
<section class="screenshots" id="screenshots">
<div class="container-fluid">
<div class="row">
<ul class="grid">
<li>
<figure>
<img src="img/02-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/02.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>User Centric Design</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/03-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/03.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Responsive and Adaptive</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/04-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/04.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Absolutely Free</p>
</a>
</div>
</figcaption>
</figure>
</li>
</ul>
</div>
<div class="row">
<ul class="grid">
<li>
<figure>
<img src="img/06-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/06.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Exclusive to Codrops</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/07-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/07.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Made with Love</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/08-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/08.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>In Sydney, Australia</p>
</a>
</div>
</figcaption>
</figure>
</li>
</ul>
</div>
</div>
</section>
and the css code looks like this:
/* ==========================================================================
Screenshots Intro
========================================================================== */
.screenshots-intro {
padding: 170px 0 100px 0;
background-color: #f6f7f9;
}
.screenshots-intro h1 {
margin-bottom: 20px;
color: #24374b;
font-weight: 400;
font-size: 22px;
}
.screenshots-intro p {
margin-bottom: 25px;
color: #778899;
}
/* ==========================================================================
Screenshots
========================================================================== */
.screenshots ul {
margin: 0;
padding: 0;
width: 100%;
}
.screenshots ul li {
float: left;
min-height: 100%;
width: 25%;
background-color: #000;
list-style: none;
}
.screenshots figure {
position: relative;
overflow: hidden;
}
.screenshots figure img {
width: 100%;
height: 100%;
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figure:hover img, .screenshots figure:focus img {
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.screenshots figcaption {
position: absolute;
top: 0;
left: 0;
padding: 25% 0;
width: 100%;
height: 100%;
background-color: rgba(63, 97, 132, 0.85);
text-align: center;
font-size: 15px;
opacity: 0;
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figcaption a {
color: #fff
}
.screenshots figcaption a:hover, .screenshots figcaption a:focus {
color: #73d0da
}
.screenshots figure:hover figcaption, .screenshots figure:focus figcaption {
opacity: 1
}
.visible {
opacity: 1
}
.screenshots figure.cs-hover figcaption {
opacity: 1
}
.screenshots figcaption i {
font-size: 35px
}
.screenshots figcaption p {
margin-bottom: 0;
text-transform: uppercase;
font-weight: 400;
}
.screenshots figcaption .caption-content {
position: absolute;
top: 50%;
left: 50%;
margin-top: -40px;
margin-left: -100px;
width: 200px;
-webkit-transform: translate(0px, 15px);
-ms-transform: translate(0px, 15px);
transform: translate(0px, 15px);
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figure:hover figcaption .caption-content, .screenshots figure:focus figcaption .caption-content {
-webkit-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
}
I know it's a lot of code, but maybe anyone of you have the idea of how to change this particular part of the layout to have it as I included in the pictures? Thanks.
This is the updated answer.
I am attaching the code and jsfiddle link with it.
Just replace the src of the images with yours to see the results.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<style type="text/css">
.container {
width: 100%;
margin: 0 auto;
}
img {
max-width: 100%;
}
/* this css is just for understanding */
.a {
background-color: red;
}
.b {
background-color: green;
}
.c {
background-color: blue;
}
.d {
background-color: black;
}
/* this css is just for understanding */
/* this is the logic to change the positions of image */
#media (min-width: 320px) {
.a,
.b,
.c,
.d {
width: 100%;
float: left;
}
}
#media (min-width: 768px) {
.a,
.b,
.c,
.d {
width: 50%;
float: left;
}
}
</style>
<body>
<div class="container">
<div class="a">
<img src="img/1.png" height="222" width="581">
</div>
<div class="b">
<img src="img/2.jpg" height="222" width="581">
</div>
<div class="c">
<img src="img/3.jpg" height="222" width="581">
</div>
<div class="d">
<img src="img/4.png" height="222" width="581">
</div>
</div>
</body>
</html>
this is the jsfiddle link