Bootstrap Expand Div - html

I'm trying to create a website that does the same thing this website does. www.treasurelimo.com If you scroll down on the homepage and look at 'popular destination'. When you hoover over the images the blue area expands and more info is seen.
I'm using wordpress but don't want to use any plugins. Right now I have those images being populated from other posts. Here is how mine works. Here is my site: www.sealfitdev.demosite.us/coaching-staff I got the CSS to place the words inside of picture, I just need it to expand when I hoover over it. Can anyone help me or point me to a post that shows how I can do that? I was looking over the bootstrap documentation and I wasn't successful. Thanks

You can accomplish the effect using CSS transitions (see some basic examples here).
See an example of this for your use-case at this JSFiddle (not a particularly clean example, but it should illustrate the concept).
I've taken the markup from your site and simplified it a little for clarity.
<div class="employee-thumb pull-left">
<div class="inner">
<img width="150" height="150" src="http://i.forbesimg.com/media/lists/people/elon-musk_416x416.jpg" />
<div class="info">
<p>Elon Musk</p>
<p>Additional information including buttons</p>
</div>
</div>
</div>
Now in the CSS, we can set .info to be absolutely positioned within the relative positioned parent, .inner. Since .inner's overflow is hidden the content can be pushed outside our visibility by adjusting the absolute positioning.
.inner {
position: relative;
overflow: hidden;
max-width: 150px;
}
.inner .info {
background-color: rgba(255,255,255,0.7);
position: absolute;
bottom: -4em;
}
On hovering over .inner, .info, the absolute positioning of bottom returns to 0, sliding the content up.
.inner:hover .info {
bottom: 0em;
}
And we animate the whole thing using a CSS transition.
.inner .info {
transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease; -o-transition: all 0.3s ease;
}

Related

HTML, CSS: Resizing the IMG with transitioning while resizing

I've got this code...
<img class="logo" src="img/logo.jpg"> <!-- Logo size is 96x96 -->
...and this
.logo {
transition: .5s;
}
.logo:hover {
transition: .5s;
width: 128px;
height: 128px;
}
It resizes on hovering, but not with transitioning. I just hover it and it instantly resizes, and I have no idea why does transition not work.
There are several things wrong with the CSS causing it not to transition.
First, as #WaisKamal said, you need to set initial states to transition from. Images size automatically in HTML but that's not a valid starting point for CSS.
Second, you need to define WHAT properties are being transitioned.
So you would need to add width and height. Or you can use the all identifier:
.logo {
display:block; //make sure the image is a block element
width: 96px;
height: 96px;
transition: all 0.5s linear;
}
.logo:hover {
width: 128px;
height: 128px;
}
Now that will work but it's going to be kind of janky since animating height/width cause page repaints.
Instead, I would suggest using a transform on the image.
.logo {
display:block; //make sure the image is a block element
// initial size is fine here because we're using a transform
transition: transform 0.5s ease-in-out;
}
.logo:hover {
transform: scale(2) // decimal notation 2 = 200% = 128x128px
}
There is no need to define the same transition property for the image and the hover pseudoclass. If you don't define transition in .logo:hover, it will take the previously set value of half a second.
The problem here is that you must specify an initial width and height for the image in order to have it resize smoothly.

CSS object-position or similar property for a photo grid

Hoping to get some input. I've been taking some online courses on web development and I've been currently playing around adding images to an html page (3x3 image grid).
First I used the transform property so I could scale the image with a .5s transition to 1.5 times the size after hovering over it with a .5 second delay.
There is an issue with the images on the left and right sides as part of them go out of the screen after scaling.
To correct this I first tried position: relative; left: 6%; but learned that position is not a property you can animate, so the image immediately moves position and then scales after .5 seconds.
My second try was with object-position: 90px; , this property does work with the delay but after it scales it seems like a big chunk of the image is cropped.
I've been trying different properties like transform-origin which kind of works but gives it a glitchy feeling as it scales and then finishes moving the image to the side losing fluidity.
Can't seem to find helpful documentation on object-position as to why part of the image crops, this property gives a fluid scaling and positioning effect but I have that cropping issue.
Here is a link to a codepen where I have this exercise:
https://codepen.io/superavd88/pen/PoqYoRJ
Any ideas would be really appreciated as I've been trying to fix this issue for the last couple of days without success.
Thanks in advance.
Welcome to SO!
You just need to wrap you images indie div and make it overflow
hidden and also i changed the grid, using flex now
.thumbnail img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
width:100%;
}
.thumbnail .img-parent:hover img {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
.img-parent{
overflow:hidden;
width: 33%;
}
img{
width: 100%}
.thumbnail {
display: flex;
flex-wrap: wrap;
}
<div class="thumbnail">
<div class="img-parent">
<img src="https://www.washingtonpost.com/wp-apps/imrs.php?src=https://arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/HB4AT3D3IMI6TMPTWIZ74WAR54.jpg&w=767" alt="deep house cleaning">
</div>
<div class="img-parent">
<img src="https://www.washingtonpost.com/wp-apps/imrs.php?src=https://arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/HB4AT3D3IMI6TMPTWIZ74WAR54.jpg&w=767" alt="deep house cleaning">
</div>
<div class="img-parent">
<img src="https://www.washingtonpost.com/wp-apps/imrs.php?src=https://arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/HB4AT3D3IMI6TMPTWIZ74WAR54.jpg&w=767" alt="deep house cleaning">
</div>
<div class="img-parent">
<img src="https://www.washingtonpost.com/wp-apps/imrs.php?src=https://arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/HB4AT3D3IMI6TMPTWIZ74WAR54.jpg&w=767" alt="deep house cleaning">
</div>
</div>
Reference for how scale property work
change CSS styles
img {
width: 30%;
float: initial;
margin: 1rem;
transition: all .5s ease-in-out;
}
.leftimg:hover{
transform: scale(1.5);
}
.rightimg:hover{
transform: scale(1.5);
}
.center:hover{
transform: scale(1.5);
}

HTML text over image while maintaining background image clickability

on my website I have a background button that is "hidden" (it blends in with the background, but is secretly a button) and it was working fine until I edited my page with text on it.
On some monitors the text covers the image, but not completely - there is space below and beside it where the image peeks through.
However, this makes the image overlap the text, breaking the illusion. Setting the z-index to -1 makes it go behind the text, but makes it unable to be clicked.
Is there any way to make something behind text clickable while staying behind text?
The "eye" between the columns is the hidden image.
Current code for image:
<a href= "/aboutme/vision.html">
<img style="position:absolute; top:354px; left:975px; width:108px; height:32px; z-index:-1" src="eye.png">
</a>
I rearranged the website layout to use a clickable div instead of an image, and now it works on click even if text is over it. I then put it in a nested div which is the size of the entire window, so the links never get misaligned based on window size:
HTML:
<div id="bodyDiv">
<div class="secret" style="position:relative; top:770px; left:1168px; width:108px; height:32px; background-color:black;" onclick="location.href='/aboutme/vision.html'"></div>
</div>
CSS:
#bodyDiv {
background-image: url("homebackgroundsmall.png");
background-repeat: no-repeat;
background-position: center;
height: 1200px;
width: 1684px;
position: absolute;
bottom: 0;
left: 50%;
margin-left: -842px;
}
The downside to this is that there is no mouse change on hover, making the secrets overly hidden. To personally fix this to make it more obvious, I made the .secret class so on hover the background portion of the div fades out by increasing the background opacity to 1 (which is black):
CSS:
.secret {
opacity: 0;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
}
.secret:hover {
opacity: 1;
}

Text is not drawn over element with lower z-index

I have a hidden list on a page (opacity:0;visibility:hidden;) that is currently necessary for my menu.
My problem is that even though the z-index of the drop down part of the menu is -1 and the z-index of the content div is 50, the text inside of the content div only draws to the right of the menu. The css style display:none is not an option due to horrible resizing of elements that I don't want to deal with. Many Google and Stack Overflow searches produced no helpful results.
I have tried a variety of display settings including inline, float:left, and others that may have fixed the problem, but they didn't.
JSFiddle here which clearly defines the problem (try the second menu to see the cutoff point):
http://jsfiddle.net/nimsson/311g9h16/5/
I would like to know either
a) the reason behind this functionality
b) a workaround / solution
or both.
Thanks,
nimsson
Simply workaround You have here: http://jsfiddle.net/311g9h16/6/
I've just change #content {position: absolute} but why display: none is not an option?? Resizing should be no problem when You set height of dropdown.
Moreover, You can do this effect with some CSS - take a look: http://www.cssterm.com/css-menus/horizontal-css-menu/simple-drop-down-menu
try this: http://jsfiddle.net/311g9h16/7/
all I did was changing the way you use positioning and adjust the width to get the text to align left.
For info on position properties go here: http://www.w3schools.com/cssref/pr_class_position.asp
#content {
background-color: rgba(204,0,0,0.4);
border: 5px solid rgba(204,51,0,1);
border-radius: 10px;
position: absolute;
bottom: 500px;
color: white;
text-align: left;
width: 500px;
z-index: 50;
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
You could add another div around the #content and re-set the page for the containing divs,
<div id="background">
.... </div>
css
#background{
z-index:-1;
position: absolute;
width:100%;
height:100%;
}

Unexpected CSS behavior when using CSS3 transitioned navigation

I have designed a navigation bar with 5 page 'links' that have equal width. When hovered over these reveal a drop-down with more links relevant to that page. See the navigation jsFiddle. This works perfectly.
The problem
When I placed the navigation bar into my site it doesn't work as intended. The drop-down animations lag quite a lot and there are white bars that randomly appear at the sides of the page (Windows 7 Ultimate, Chrome 24, other OS's and browsers untested). See the site here.
The white bars
Example markup
<nav id="nav">
<ul id="nav1">
<li>
<span>Games</span>
<div>
<span>All Games</span>
<span>Free Games</span>
...
</div>
</li>
...
</ul>
</nav>
Animation CSS
#nav1 > li > div {
position: absolute;
margin: 5px 0 5px -45px;
top: 0;
left: 50%;
max-height: 30px;
width: 90px;
opacity: 0;
overflow: hidden;
-webkit-transition:
width 500ms,
max-height 500ms,
opacity 200ms ease 400ms,
margin-left 500ms;
}
#nav1 > li:hover > div {
max-height: 200px;
width: 200px;
opacity: 1;
margin-left: -100px;
-webkit-transition:
width 500ms,
max-height 1s ease 500ms,
opacity 200ms,
margin-left 500ms;
}
What I tried
After unsuccessfully spending an hour looking for the problem, I decided to make a jsFiddle of my entire site to see if that would identify the problem. To my surprise it works fine in the jsFiddle.
Edit: After more testing I have determined that the problem occurs when a transition on the width or height of #nav1 > li > div completes. It is also definitely related to the transitions. Not sure if this helps.
My question
If anyone could provide some insight into the problem, it would be much appreciated. I have absolutely no clue what the cause of the problem is or how to fix it.
Note: The navigation is currently only animated in Chrome.
The problem is:
#mainbar
Get rid of that and see if your problems don't go away. But it's more than that. This encompasses the entire width of the DOM:
width:100%;
And it has a higher z-index than the #wapper el, which is only taking up a part of the page. The #mainbar el is overlaying the areas on the side where #wrapper isn't. But because there isn't anything there (style-wise) you get the default white of the browser bg; hence, the white bars on the side.
If you think I'm wrong, set
#mainbar{width:700px;}
You'll see your white bars have expanded to new uncovered regions. :P
Simple solution:
#wrapper{z-index:0;}
That should solve it.