bootstrap caption in jumbotron - html

Is it possible to caption a background image that I put in a Bootstrap Jumbotron? I would like the caption to slide up from the bottom and be semi-transparent. The thing is, my background image is in the css, like this:
.jumbotron {
background-image: url('../img/honeycomb.jpg');
background-repeat: no-repeat;
background-position: 100%;
padding: 200px 0 140px 0;
margin-bottom: 70px;
text-align: center;
padding-bottom: 50px;
}
I have searched for answers, but all are related to inline images. Thanks for any insight you can give.

My_neck_hurts, have a look at this Fiddle.
This code will use css to get the image into the jumbotron and it also has a caption that slides up from the bottom.
I added some notes in the css to help if you want to change some things at any time.
Normally you would set the width via the class in the css but using bootstrap here we just use the col-lg-X etc to control this as you will see in the code.
This way it keeps it responsive.
In the css comments also show where to adjust the height for how far you want the slider to come up. If you want to slider to cover the full height then there is two places you need to change, both are commented so it is easy to find.
Hope it help to get you started.
body {
padding-top: 50px;
}
.block {
height: 600px;
padding-top:20px;
}
.whatishere:before {
content: "?";
position: absolute;
top:20%;
left:11%;
font-weight: 800;
background: black;
text-shadow: 0 0 5px white;
color: black;
width: 100px;
height: 100px;
-webkit-border-radius: 120px;
-moz-border-radius: 120px;
border-radius: 120px;
text-align: center;
font-size: 30px;
line-height: 100px;
-moz-transition: all 0.6s ease;
opacity: 0.5;
}
.whatishere:hover:before {
opacity: 0;
}
/* The Box Style */
.box {
border: 5px solid #fff;
cursor: pointer;
height: 300px;
float: left;
margin: 5px;
position: relative;
overflow: hidden;
/* width: 300px; */ /* use col-lg-X to set the width */
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
}
/* Caption Style */
.caption {
background-color: rgba(0,0,0,0.4);
position: absolute;
color: #fff;
z-index: 100;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
left: 0;
}
/* The Slide Caption style */
.slide-caption {
height: 150px; /* set the height of the caption div */
/* width: 300px; */ /* use col-lg-X to set the width */
display: block;
bottom: -150px; /* hide the caption for how tall it is */
line-height: 20px;
text-align: center;
}
/* The Slide Caption :hover Behaviour */
.box:hover .slide-caption {
-moz-transform: translateY(-100%);
-o-transform: translateY(-100%);
-webkit-transform: translateY(-100%);
opacity: 1;
transform: translateY(-100%);
}
.image {
background-image: url(http://img1.goodfon.su/original/1920x1080/b/b3/soty-pchela-med-fon-nasekomoe.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

I didn't really get what you wanted to do with that image. But if your issue is that you can't edit the HTML to insert an inline image you can still put your image in a :before or :after like this :
.jumbotron:after {
content: url('../img/honeycomb.jpg');
display: inline;
}
At that point, you can apply the solutions you read for inline images. You can also give it an absolute position, etc.
Look at this jsfiddle. Is this the kind of effect you want ? Or do you want it to be animated ?
https://jsfiddle.net/bdasilva/kmjuz212/1/
Hope it helped.

My_neck_hurts, Ok so you are almost there.
Just wanted the body to hold the image.
Here is the Fiddle with it doing that.
I've changed the background of the jumbotron to be transparent if that helps.
The image is a public image on the internet. It came up in a google search.
.bodyimage {
background-image: url(http://img1.goodfon.su/original/1920x1080/b/b3/soty-pchela-med-fon-nasekomoe.jpg);
background-position: center;
background-repeat: no-repeat;
height:100vh;
width:100%;
z-index: -100;
}
.bg-clear {
background-color: rgba(250,250,250, 0.3);
}

Related

CSS transition for border is pushing the button down

So I have a border transition on hover and on active for a circular button so the border increases in size. However, the border expands downwards, pushing the button downward. Is there any way to make it so the border expands evenly outward? I've searched this site and others for solutions, and while there are similar questions, they don't answer this specifically.
Thanks!
HTML:
<center><a class="btn" href="#"></a></center
CSS:
.btn {
vertical-align: top;
transform: translateY(20px);
background-color: black;
display: inline-block;
height: 300px;
width: 300px;
border-radius: 50%;
border: 0px solid red;
transition: border-width 0.1s ease-in;
margin: 0.5em;
}
.btn:hover {
border: 20px solid red;
}
.btn:focus {
border: 75px solid red;
}
Instead of using border, you can generate a border effect by placing a pseudoelement behind the button, and transforming its scale on hover and focus as needed.
*also note that <center> is deprecated in HTML5. You can center content with CSS instead.
.btn {
display: block;
margin: 5rem auto;
position: relative;
background-color: black;
height: 300px;
width: 300px;
border-radius: 50%;
transition: border-width 0.1s ease-in;
}
.btn:before {
content: '';
display: block;
position: absolute;
background: red;
border-radius: 50%;
width: 300px;
height: 300px;
z-index: -1;
transition: all .1s ease;
}
.btn:hover:before {
transform: scale(1.1);
}
.btn:focus:before {
transform: scale(1.25);
}
<a class="btn" href="#"></a>

Adding border on hover shifts surrounding elements

Just hover on 'a headline' in the snippet below and you will see how elements are moving. Why?
There's no margin .. And they're only moving when I add border to the inline-block element. Try to add more border width in section.twelve a like:
section.twelve a {
border-bottom: 10px solid #FFFAFF;
}
But if you remove the border everything's fine.. Why is this behavior ? and is it only for border?
I just want to add any styles to the element without effecting the others.
section{
position: relative;
height: 300px;
padding: 15px 80px;
z-index: 1;
}
section h1{
font-size:3em;
font-weight: 100;
line-height: 1.3;
}
section a {
position: relative;
display: inline-block;
text-decoration: none;
transition: all 0.3s ease-in-out;
vertical-align: bottom;
}
section.twelve {
background: #121A5A;
color: #FFFAFF;
}
section.twelve a {
color:#D8315B;
font-weight: 700;
overflow: hidden;
padding: 0px 5px;
transition all 0.2s ease;
border-bottom: 5px solid #FFFAFF;
}
.twelve a:before{
content: "";
top:0; left: 0;
position: absolute;
width:100%; height: 100%;
background: #FFFAFF;
z-index: -1;
transition: all 0.2s ease;
transform: translateX(100%);
}
.twelve a:hover::before {
transform: translateX(-95%);
background: #D8315B;
}
.twelve a:hover{
color: #FFFAFF;
transform: translateX(5px);
border-bottom: 1px solid #FFFAFF;
}
<section class="twelve">
<h1>Write a headline that makes people do kind of a double take whenthey read it.</h1>
</section>
When you add, or change the width, of a border, that changes the size of the element. Hence, by adding the border on hover, the box grows to occupy more space, which naturally shifts the position of surrounding text / elements.
One method to resolve this issue is to always have the border present, so the size of the box is fixed. When the border shouldn't be visible, it's transparent.
Here's an example:
section {
position: relative;
height: 300px;
padding: 15px 80px;
z-index: 1;
}
section h1 {
font-size: 3em;
font-weight: 100;
line-height: 1.3;
}
section a {
position: relative;
display: inline-block;
text-decoration: none;
transition: all 0.3s ease-in-out;
vertical-align: bottom;
}
section.twelve {
background: #121A5A;
color: #FFFAFF;
}
section.twelve a {
color: #D8315B;
font-weight: 700;
overflow: hidden;
padding: 0px 5px;
transition all 0.2s ease;
border-bottom: 5px solid transparent; /* ADJUSTMENT */
}
.twelve a:before {
content: "";
top: 0;
left: 0;
position: absolute;
width: 100%;
height: 100%;
background: #FFFAFF;
z-index: -1;
transition: all 0.2s ease;
transform: translateX(100%);
}
.twelve a:hover::before {
transform: translateX(-95%);
background: #D8315B;
}
.twelve a:hover {
color: #FFFAFF;
transform: translateX(5px);
border-bottom: 5px solid white; /* ADJUSED */
}
<section class="twelve">
<h1>Write a headline that makes people do kind of a double take whenthey read it.</h1>
</section>
Yes, on hover you are changing element's border, so, element's total height also changes

Whats wrong with my code [CSS]

I'm not so good with CSS to start with, however I'm really looking on improving myself.
Now what I wanted to acomplish is an expandable window, that would fit the size of the content with the animation of expanding.
My main issue is the #expand:hover and rightbut:hover doesn't work at all. And the fit div to content also doesn't work as when I go animate percentage it doesn't show the animation at all.
I know the code could be a completly miss however I do need you assistance, as I know you all know better than me.
Thank you!
https://jsfiddle.net/VisualTech48/0r27vgv4/1/
/* Checkbox Hack */
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
#rightbut {
position: absolute;
top: 16px;
right: 26%;
color: #7a7a7a;
}
#rightbut:hover {
color: #dddddd;
}
#expand {
text-transform: uppercase;
font-size: 150%;
border-width: 100%;
backround: #d4d4d4;
color: #7a7a7a;
transition: 0.5s;
/* Animation time */
-webkit-transition: 0.5s;
/* For Safari */
}
}
#expand:hover {
color: #dddddd;
}
label {
cursor: pointer;
}
p {
color: black;
}
/* Default State */
div {
background: #d4d4d4;
width: 75%;
height: 35px;
overflow: hidden;
transition: 0.8s;
/* Animation time */
-webkit-transition: 0.8s;
/* For Safari */
}
/* Toggled State */
div:hover {
background: #b2b0b0;
}
input[type=checkbox]:checked ~ div {
height: 290px;
background: #fff;
}
Very Simple changes. Changes made in your jsfiddle Demo
Modified below css..
/* Toggled State */
div:hover{
background: #b2b0b0;
height:auto;
}
input[type=checkbox]:checked ~ div {
height:auto;
background: #fff;
}
Added a New Class
input[type=checkbox]:unchecked ~ div {
// height:290px;
background: #fff;
}
Apparently, you can't animate height to auto, but you can animate max-height to a fixed number. It'll just fit the text because it's max-height
Demo at CodePen because it has "tidy" and AutoPrefixer built-in.
#expand {
text-transform: uppercase;
font-size: 150%;
border-width: 100%;
background: #d4d4d4;
color: #7a7a7a;
transition: 0.5s;
}
label {
cursor: pointer;
}
div {
background: #d4d4d4;
width: 75%;
max-height: 35px;
overflow: hidden;
transition: 0.5s;
}
div:hover {
background: #b2b0b0;
max-height: 5000px;
}
<div>
<label id="expand" for="expand-1">I'm a toggle</label>
<p>I'm controlled by toggle. No JavaScript!I'm controlled by toggle. No JavaScript!I'm controlled by toggle. No JavaScript!</p>
<br>
<p>hi</p>
</div>

Center horizontally and vertically text in relative height div

I want to center my text in a relative height div which contains an image. I use absolute position but when my text is on two lines, the text is not centered. I've already tried to use a table but it doesn't work due to the img.
HTML:
<div id="hubs">
<h3>Nos Hubs</h3>
<hr>
<a class="thumbnail vignette-hub" href="http://kkw.fr">
<img style="opacity: 0.6;filter: alpha(opacity=60);" alt="AĆ©roport de Nantes" src="http://kkw.fr/uploads/upload-center/nantes-vue-aerienne091501270208.png" width="100%" />
<p class="txt-hub-image">
Hub de</br>Nantes
</p>
</a>
</div>
CSS :
.txt-hub-image {
z-index: 100;
position: absolute;
left: 0px;
top: 50%;
width: 100%;
height: 100%;
text-align: center;
text-decoration: none;
color: white;
font-weight: bold;
font-size: 16px;
}
.vignette-hub {
position: relative;
width: 25%;
min-width: 135px;
}
.thumbnail {
display: block;
padding: 4px;
margin-bottom: 20px;
line-height: 1.42857143;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
-webkit-transition: border .2s ease-in-out;
-o-transition: border .2s ease-in-out;
transition: border .2s ease-in-out;
}
.thumbnail > img,
.thumbnail a > img {
margin-right: auto;
margin-left: auto;
}
a.thumbnail:hover,
a.thumbnail:focus,
a.thumbnail.active {
border-color: #337ab7;
}
.thumbnail .caption {
padding: 9px;
color: #333;
}
Do you have any ideas ?
There are a few changes required to your snippet to make it automatically work for all dimensions:
p tags by default have a margin-top. If you don't reset it, then absolutely positioning it at 50% would become 50% + margin-top. This needs to be reset.
When you absolutely position an element at top: 50%, the box gets positioned at 50% height of the container and text keeps getting added from that position on. So, to match the center of the text block with the center of the parent, you have to translate the box with the text up by 50% of its own size. This can be done by adding transform: translateY(-50%).
You don't need to add a height: 100% on the p tag and it can be removed.
Note: Using transform method for positioning needs CSS3 support but I assume this shouldn't be a problem because you are already using transition.
If you want to support non CSS3 compatible browsers, have a look at the other approaches mentioned here. I have added a different answer just to explain the first two points I had mentioned above.
.txt-hub-image {
z-index: 100;
position: absolute;
left: 0px;
top: 50%;
width: 100%;
text-align: center;
text-decoration: none;
color: white;
font-weight: bold;
font-size: 16px;
/* added to fix the vertical centering */
margin-top: 0px;
transform: translateY(-50%);
}
.vignette-hub {
position: relative;
width: 25%;
min-width: 135px;
}
.thumbnail {
display: block;
padding: 4px;
margin-bottom: 20px;
line-height: 1.42857143;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
-webkit-transition: border .2s ease-in-out;
-o-transition: border .2s ease-in-out;
transition: border .2s ease-in-out;
}
.thumbnail > img,
.thumbnail a > img {
margin-right: auto;
margin-left: auto;
}
a.thumbnail:hover,
a.thumbnail:focus,
a.thumbnail.active {
border-color: #337ab7;
}
.thumbnail .caption {
padding: 9px;
color: #333;
}
<div id="hubs">
<h3>Nos Hubs</h3>
<hr>
<a class="thumbnail vignette-hub" href="http://kkw.fr">
<img style="opacity: 0.6;filter: alpha(opacity=60);" alt="AĆ©roport de Nantes" src="http://kkw.fr/uploads/upload-center/nantes-vue-aerienne091501270208.png" width="100%" />
<p class="txt-hub-image">
Hub de</br>Nantes
</p>
</a>
</div>
Here is a demo fiddle as the snippets feature seems to be down.
Change your .txt-hub-image class, top value from 50% to 25%.

Cleaning up CSS jitters

I've built these circles that expand a border when there is a mouseover. The only problem I'm getting now is some times the circle will jitter/shake. And it becomes more apparent when I set the transition: all .1s ease-in-out; to more than .2s.
Is there a work around to this problem or is that just the way it is?
Here's the code in JsFiddle
Thanks for any and all help!
EDIT: I am transitioning the dimensions (width and height) of the circles to maintain centering. I realize this is causing the jittering during the transition. Is there a work around?
I got rid of the percent values for top/left positioning, cleaned up the margins and aligned the border-width of the outer circle:
Here is a DEMO
.box {
position: relative;
width: 220px;
height: 220px;
float: left;
margin-right: 50px;
}
.clearcircle {
position: absolute;
top:15px;
left:15px;
width: 190px;
height:190px;
border-radius: 100%;
background-color: transparent;
border: 5px solid #c0392b;
transition: all .2s ease-in-out;
}
.clearcircle:hover {
width:220px;
height: 220px;
top: 0px;
left: 0px;
border: 5px solid #c0392b;
}
.circle {
position: absolute;
top:50%;
margin-top: -100px;
left: 50%;
margin-left:-100px;
width: 200px;
height:200px;
border-radius: 100%;
background-color: #e74c3c;
overflow: hidden;
transition: all .2s ease-in-out;
}
.circle p {
position:relative;
text-align: center;
top: 50%;
margin-top: -55px;
color: white;
transition: all .3s;
}
.circle:hover{
background-color: #e97468;
}
Don't transition the width and the height. Keep the same width and height and just transition the border of your outer circle.
For your inner circle (.circle), set a white border 12px solid #ffffff. Now it is always in the same place relative to the outer circle, and now it will not have to change size. Also the title can not jump around because it is always in the same position.
For the outer circle, when it is not hovered, make sure it has the same size and border as when it is, but make the border white, 5px solid #ffffff.
I think you can then also do away with a lot of your extra positioning.
Here is a modified jsFiddle so you can take a look, and here is the CSS modified:
.box {
position: relative;
width: 220px;
height: 220px;
float: left;
margin-right: 50px;
text-align: center;
}
.clearcircle {
width: 225px;
height:225px;
border-radius: 100%;
background-color: transparent;
border: 5px solid #ffffff;
transition: all .2s ease-in-out;
}
.clearcircle:hover {
border: 5px solid #c0392b;
}
.circle {
width: 200px;
height:200px;
border: 12px solid #ffffff;
border-radius: 100%;
background-color: #e74c3c;
overflow: hidden;
transition: all .2s ease-in-out;
}
.circle p {
position:relative;
text-align: center;
color: white;
transition: all .3s;
}
.circle:hover{
background-color: #e97468;
}
Incidentally, putting a div or a p in your a tag breaks the tag for validated XHTML. You may want to use a div instead, with an "on click" action added that causes it to behave as a link.
Debounce jitter by margin: 0 -12%; if adding padding padding: 0 12%;
menu li a:hover {
margin: 0 -12%;
padding: 0 12%;
color: #fff;
background: #ff5a5f;
display: inline-block;
}