Center content over a image - html

I am trying to center a little self made caption over a image, but its not quite working right. I'm not sure what I'm doing wrong, but here is a fiddle that shows what i am working with: https://jsfiddle.net/efvL28o0/.
html
<div class= "container-fluid">
<div class="row">
<div class="col-md-3">
<a href="" class="rel-tile" >
<img src="http://via.placeholder.com/1000x500" width="100%">
<span class="btn-center text-center caption-custom">About Me</span>
</a>
</div>
<div class="col-md-3">
<a href="" class="rel-tile">
<img src="http://via.placeholder.com/1000x500" alt="" width="100%">
<span class="btn-center text-center">Lineage</span>
</a>
</div>
<div class="col-md-3">
<a href="" class="rel-tile">
<img src="http://via.placeholder.com/1000x500" alt="" width="100%">
<span class="btn-center text-center">Contact Me</span>
</a>
</div>
<div class="col-md-3">
<a href="" class="rel-tile">
<img src="http://via.placeholder.com/1000x500" alt="" width="100%">
<span class="btn-center text-center">Gallery</span>
</a>
</div>
</div>
</div>
css
.rel-tile {
position: relative;
}
.btn-center {
position: absolute;
top: 45%;
opacity: 0.6;
left:45%;
background-color: black;
color: white;
text-decoration: none;
}
Ideally it would float exactly in the middle regardless of the size i set for the btn-center.
Thank you!

https://jsfiddle.net/bsalex/byqa4qng/3/
Change .btn-center styles to:
.btn-center {
position: absolute;
top: 50%;
opacity: 0.6;
left:50%;
background-color: black;
color: white;
text-decoration: none;
transform: translate(-50%, -50%);
}
The main part here is transform: translate(-50%, -50%);.
It is one of the common centering techniques.

Related

Put button in same position in boxes with different sizes

I am using an image gallery. Each image has different sizes, masonry style. How can I place a button inside each image in the same position with different sizes? I want to put the button in the upper right corner.
css
.EyeG{
cursor: pointer;
position: absolute;
background-color: white;
background-image: url("/assets/eye.svg");
background-position: 13px 13px;
background-repeat: no-repeat;
height: 15%;
width: 15%;
margin-top: -329px;
right: 13px;
border-radius: 8px;
opacity: 1;
}
HTML
<ngx-masonry [options]="masonryOptions" [useImagesLoaded]="true">
<ngxMasonryItem *ngFor="let p of products" class="masonry-item">
</div>
<img [src]="imagMap.get(p.id)">
<figcaption class="EyeG"></figcaption>
</ngxMasonryItem>
</ngx-masonry>
Try this
.masonry-item { position: relative }
.EyeG{
cursor: pointer;
position: absolute;
background-color: white;
background-image: url("/assets/eye.svg");
background-position: 13px 13px;
background-repeat: no-repeat;
height: 15%;
width: 15%;
border-radius: 8px;
opacity: 1;
top:50%;
left:50%;
transfomrm: translate(-50%, -50%);
}
Attached codepen link, please have look.
Let me know if you not got your solution here. Will help you
<div class="header">
<h1>Responsive Masonry.js Grid</h1>
<p>A horizontal image card grid built with masonry.js</p>
</div>
<div class="container">
<div class="grid-sizer"></div>
<div class="gutter-sizer"></div>
<a class="item" href="#">
<img src="https://placehold.it/350x300">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/350x200">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/300x290">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/400x300">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/350x350">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/400x300">
<sapn class="EyeG"></span>
</a>
<a class="item" href="#">
<img src="https://placehold.it/400x500">
<sapn class="EyeG"></span>
</a>
</div>
https://codepen.io/pgurav/pen/zYYXoNj

Responsive mosaic of images as backgrounds in CSS/HTML - borders and capture texts needed

I have created a responsive mosaic of images (as div backgrounds). The problem is that I can not add borders and caption texts. In the foto below you can see the actual result and desired result.
Jsfiddle
I need borders:
#foto1 - border-right:2px solid #fff;
#foto2 - border-bottom:2px solid #fff;
I add borders to #foto1 and #foto3 but they don' t appear.
Containers .caption should contain caption text. When I enter some text, the container changes it's height. I need it to stay the same height..
HTML
<div class="table">
<div class="tablerow">
<div class="tablecell">
<a href="#">
<div id="foto1" style="padding-top:100%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x513/0c33/768d432/none/11314/UVTR/image_content_3669106_20180619165415.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">
</div>
</div>
</a>
</div>
<div class="tablecell">
<a href="#">
<div id="foto2" style="padding-top:50%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x513/0c0/768d432/none/11314/VMNM/180731ftv-carretera-corralejo-8melian_3847760_20180804162359.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">
</div>
</div>
</a>
<a href="#">
<div id="foto3" style="padding-top:50%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x512/0c40/768d432/none/11314/TKDX/papas-diez-tipos_3850905_20180807065646.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">
</div>
</div>
</a>
</div>
</div></div>
CSS
.table{display:table;width:70%;}
.tablerow{display:table-row;}
.tablecell{display:table-cell;width:50%;vertical-align:top;}
write some CSS
.table {
display:table;
width:70%; }
.tablerow {
display:table-row;
}
.tablecell {
display:table-cell;
width:50%;
vertical-align:top;
}
.tablecell a div:not (.caption) {
position:relative;
}
.caption {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
background: rgba(255,255,255,0.7);
padding: 5px;
color: #000;
border-radius: 2px;
line-height: 1.2;
}
#foto1 {
border-right:2px solid #fff;
}
#foto2 {
border-bottom:2px solid #fff;
}
<div class="table">
<div class="tablerow">
<div class="tablecell">
<a href="#">
<div id="foto1" style="padding-top:100%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x513/0c33/768d432/none/11314/UVTR/image_content_3669106_20180619165415.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">caption Text</div>
</div>
</a>
</div>
<div class="tablecell">
<a href="#">
<div id="foto2" style="padding-top:50%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x513/0c0/768d432/none/11314/VMNM/180731ftv-carretera-corralejo-8melian_3847760_20180804162359.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">caption Text</div>
</div>
</a>
<a href="#">
<div id="foto3" style="padding-top:50%;background:url(http://files.softicons.com/download/web-icons/simplistic-collection-icons-by-mediajon/png/48x48/lock.png) center no-repeat,url(https://www.canarias7.es/binrepository/768x512/0c40/768d432/none/11314/TKDX/papas-diez-tipos_3850905_20180807065646.jpg) center no-repeat;background-size:auto, cover;">
<div class="caption">caption Text</div>
</div>
</a>
</div>
</div>
</div>
https://jsfiddle.net/c2a4zh38/39/

Menu logos are in the center of the div but not the titles - Bootstrap

I have been trying to create a responsive menu for the mobile browser of my site and it has four links. I have given 25% width for each of them. The problem is, although its logos stay center their titles don't. You can notice for the snippet that the titles are not in the center of their div.
What is the problem here? What am I doing wrong? Can you suggest how can I keep these titles center as well?
this is the current state:
I'm trying to make it something like this:
The snippet:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK1
</div>
</a>
<a href="calculator-home.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK222
</div>
</a>
<a href="contact.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK33333
</div>
</a>
<a href="about.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK4444444
</div>
</a>
</div>
</div>
Columns should be direct child of rows.
Add text center class to the columns. Put the anchor tag inside of columns and make it display:block. And the image and menu title should be placed inside the anchor tag.
/*This css is not required. */
img{
width:25px;
height:25px;
}
a.main-link:link,
a.main-link:visited {
text-decoration: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
</div>
</div>
If you change the html code and add the image before the text inside the anchor tag then add text-align: center you'll get the same result
check my code:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
.main-link {
text-align: center
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK1
</span>
</a>
<a href="calculator-home.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK222
</span>
</a>
<a href="contact.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK33333
</span>
</a>
<a href="about.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK4444444
</span>
</a>
</div>
</div>

How to do auto slide for divs [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have three main div for movie poster. I want that three div to auto slide and also want left and right navigation button. How can it be done?
HTML Code
<div class="movie-review">
<div class="single-movie">
<img src="style.jpg" width="250" >
<div class="description">
<span class="movie_title">Movie Title</span><hr>
<span class="rating">Rating:</span>
</div>
</div>
<div class="single-movie">
<img src="rasputin.jpg" width="250" >
<div class="description">
<span class="movie_title">Movie Title</span><hr>
<span class="rating">Rating:</span>
</div>
</div>
<div class="single-movie">
<img src="spirit.jpg" width="250" >
<div class="description">
<span class="movie_title">Movie Title</span><hr>
<span class="rating">Rating:</span>
</div>
</div>
</div>
CSS Code
.single-movie {width:250px; height:370px; float:left;}
.single-movie img {position:absolute; -webkit-transition: 0.4s ease; transition: 0.4s ease;}
.single-movie img:hover {-webkit-transform: scale(1.08); transform: scale(1.08);}
.description {background:rgba(0,0,0,0.9); color:#fff; padding:5px 9px; position:relative; top:290px;}
.movie_title {font-size:22px;}
.rating {color:#ff6000; font-size:18px;}
You can do that with slick slider. Here is my codepen link
$('.movie-review').slick();
You can do this with Bootstrap carousel
$(document).ready(function() {
$('#media').carousel({
pause: true,
interval: false,
});
});
/* carousel */
.media-carousel
{
margin-bottom: 0;
padding: 0 40px 30px 40px;
margin-top: 30px;
}
/* Previous button */
.media-carousel .carousel-control.left
{
left: -12px;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
height: 40px;
width : 40px;
margin-top: 30px
}
/* Next button */
.media-carousel .carousel-control.right
{
right: -12px !important;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
height: 40px;
width : 40px;
margin-top: 30px
}
/* Changes the position of the indicators */
.media-carousel .carousel-indicators
{
right: 50%;
top: auto;
bottom: 0px;
margin-right: -19px;
}
/* Changes the colour of the indicators */
.media-carousel .carousel-indicators li
{
background: #c0c0c0;
}
.media-carousel .carousel-indicators .active
{
background: #333333;
}
.media-carousel img
{
width: 250px;
height: 100px
}
/* End carousel */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<h2>Media Slider Carousel BS3</h2>
</div>
<div class='row'>
<div class='col-md-8'>
<div class="carousel slide media-carousel" id="media">
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
</div>
<a data-slide="prev" href="#media" class="left carousel-control">‹</a>
<a data-slide="next" href="#media" class="right carousel-control">›</a>
</div>
</div>
</div>
</div>
See Full Page Demo

I want a grand grandchild of a <div> to appear in front of everything

Please I'd like to make a grand grandchild of a div appear in front of everything in the document, while other children and grandchildren of that div may be subject to change of order.
I tried changing the z-index of everything and it doesn't work.
Please help. The problem is that the captions are behind the circle and i want them to be in front of the circle. This is the result of the code
otekit.com
This is the html, i want the divs with the class "carousel-captions" to be on top of everything, even on top of the img "circle-slider", which is on top of the images inside the divs with the class "carousel-captions".
<div id="carousel1" class="carousel slide main" data-ride="carousel">
<div class="carousel-inner " role="listbox">
<div class="item active">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg11.jpg" alt="First slide image" class="center-block slider-img">
</div>
<div class="item">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg7.jpg" alt="Second slide image" class="center-block slider-img">
</div>
<div class="item">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg22.jpg" alt="Third slide image" class="center-block slider-img">
</div>
</div>
<img id="circle-slider" src="img/slider/circle.png" class="circle-slider img-responsive " alt="Placeholder image">
<a class="left carousel-control" href="#carousel1" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left" style="color: #ed1c3b; opacity: 0.5" aria-hidden="true"></span><span class="sr-only">Previous</span></a><a class="right carousel-control" href="#carousel1" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right" style="color: #ed1c3b ; opacity: 0.5" aria-hidden="true"></span><span class="sr-only">Next</span></a>
</div>
</div>
This is the CSS
.carousel {
position: relative;
max-height: 600px;
overflow: hidden;
}
.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
}
.carousel-inner > .item {
position: relative;
overflow: hidden;
}
.carousel-caption {
position: absolute;
right: 15%;
top: 30vw;
left: 15%;
z-index: 10;
padding-top: 20px;
padding-bottom: 20px;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.circle-slider{
position: absolute;
bottom: -50%;
left: 50%;
z-index: 15;
width: 60%;
padding-left: 0;
margin-left: -30%;
text-align: center;
list-style: none;
max-width:640px;
opacity: 0.5;
}