Make text appear on the side when hover - html

I am using for the first time this forum, so if I am missing some crucial elements let me know.
My goal: I am trying to create 4 clickable image (in a box layout) in which when the mouse goes over, I would like a slight animation to show an icon on the image AND i want at the same time, a descriptive text that would appear on its side of the image.
My situation: I have the images set up in the dimension I want, and the little animation.
My problem: I have tried many, many things, but can t managed to make the text appear on the side of the image when the mouse hovers on the image.
Here is the Html:
<div class="video-container">
<a href="" class="thumb-unit" style="background-image: url(/assets/img/video/thumb1.jpg)">
<div class="thumb-overlay">
<strong>PLAY</strong>
</a> </div>
(above structure 4 times)
And here is the css:
.videos
background: #e1f3f6
h3
margin: 0
text-align: center
font-family: "Quicksand", sans-serif
letter-spacing: 1em
color: #deb75c
padding-top: 70px
font-weight: 300
.video-container
max-width: 930px
margin: 0px auto
padding-top: 88px
padding-bottom: 70px
+clearfix
.thumb-unit
overflow: hidden
display: block
width: 50%
position: relative
padding-top: 20%
background: pink
float: left
background:
position: center center
repeat: no-repeat
size: cover
.thumb-overlay
+position(absolute, 100% 0px null 0px)
height: 100%
background: fade-out(#6693b0, 0.3)
+transition
text-align: center
strong
padding: 30px
display: block
Color: white
font-weight: 400
text-transform: uppercase
font-size: 17px
background:
image: url(/assets/img/icon/play.png)
position: center 70px
repeat: no-repeat
h4
border: 2px solid red
position: absolute!important
width: 300px!important
right: 300px!important
visibility: visible!important!important
&:hover .thumb-overlay
+position(absolute, 0% 0px null 0px)
as you can see, the code reflects my current situation.
If you have any insights, thank you very much!!!

i have slightly adjusted your code, not sure what else is on your page but hopefully this will make sense and you can add it into your code.
<div class="video-container">
<a href="#">
<div style="background-image:url('Thumb.jpg');">
<strong>PLAY</strong>
</div>
<div>
This is the display text you want to display.
</div>
</a>
</div>
and the css
.video-container
{
width:100px;
height:100px;
margin: 5px;
float:left;
}
.video-container > a > div:nth-child(1)
{
height:100px;
width:100px;
float:left;
}
.video-container > a > div:nth-child(2)
{
display:none;
height:100px;
width:100px;
margin:-100px 0px 0px 100px;
float:left;
}
.video-container > a:hover > div:nth-child(2)
{
display:block;
}
i think it works how you want, its hard as not sure what the other code on your page is etc. i have changed some dimensions to make it a bit easier to work with. any comments on this will be greatfull

Related

DIV around a centered image

I am trying to display an image, centered vertically and horizontally on a screen (which in my case, is a modal screen). The image must be a maximum of 80% high, and 80% wide. It can be landscape, square or portrait.
I have achieved that. But now I need to add a div, fitted tightly around the image, so that I can apply a text-over effect.
This is what I have so far.
https://jsfiddle.net/Cralis/1w8d4zx5/
<div class="imageContainer">
<img id="imgContainer" class="fullimage animated fadeIn" src="http://cameraflare.com/photostore/23d255d8-e259-47ee-be2d-fae68c730f6d/afda43dd-5a81-40b2-8161-d1f222689d3f.jpg">
<h2>
<span>The one and only:
<span class='spacer'></span>
<br />
<span class='spacer'></span>
The Hulk
</span>
</h2>
</div>
I am trying to achieve what this tutorial shows, except, their demo is aligned left on the screen. My image is centered.
https://css-tricks.com/text-blocks-over-image/
How can I get the imageContainer div to 'hug' the image?
Not pretty sure but i think what you are looking for is the following:
Set your .imageContainer as display: inline-block and add it text-align: left
Set the parent of image container to text-align: center
So you will get your div centered but you will also wrap/hug the image with the border. Take a look here:
https://jsfiddle.net/0k3wrfxt/
you can use css3 flexbox concept to achieve this.
add the following styles to the parent container of your image
display:flex;
align-items:center;
justify-content:center;
and remove the margin:100px; on your .imageContainer ,it will work fine .I'm added the snippet below.
html,body{
width:100%;
height:100%;
display:flex;
align-items:center;
justify-content:center;
}
.fullimage {
vertical-align: top;
display: block;
margin: auto;
border-radius: 7px;
}
.imageContainer {
max-height: 80vh;
max-width: 80vw;
border: solid;
/*margin: auto;
margin-left:100px;*/
position: absolute;
padding: 0;
}
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0);
/* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
h2 span.spacer {
padding: 0 5px;
}
<div class="imageContainer">
<img id="imgContainer" class="fullimage animated fadeIn" src="http://cameraflare.com/photostore/23d255d8-e259-47ee-be2d-fae68c730f6d/afda43dd-5a81-40b2-8161-d1f222689d3f.jpg">
<h2>
<span>The one and only:
<span class='spacer'></span>
<br />
<span class='spacer'></span>
The Hulk
</span>
</h2>
</div>

setting up css background margins

I'll start by saying that my css skills are very weak.
Here is the site, and I was trying to add some margins to this background so I can see all the content. I now understand that I am not able to use margins on a background, so what are my options here?
Here is my HTML
<body>
<div id="container">
<nav id="navigation">
<ul>
<li>Homepage</li>
</ul>
</nav>
</div>
</body>
and here is my css
body {
background: url('images/prices.jpg');
min-height: 100%;
height: 100%;
}
#btn {
color: #FAF3BC;
background: #4FB69F url('images/texture.png') no-repeat right bottom;
padding: 15px 30px;
margin: 150px 0px;
border-top: 5px;
border-radius: 25px;
text-decoration: none;
text-transform: uppercase;
}
I am also having issues with the homepage button, I would like some room there as well, but I've tried couple of things like padding and margin and was not able to do it...
I would appreciate any help .... here is the page live, if you like to take a peak http://brewstahs.com/menu.html
I know why your css is not working. The most basic use of CSS is to create a layout, but even though your DOM contains div representing container and footer, the height occupied by each is
equal to the height of its content(because you have not provided any height to the div containers).In short,
margin : 150px 0px does not work because the parent container(nav) does not have that height to provide the margin to it. So provide a height to nav and div and it will work.
Use tools like Firebug to see your layout and see where you're going wrong.
All the best!!
Maybe you should try with background-position attribute:
http://www.w3.org/wiki/CSS/Properties/background-position
What do you want to do?
In case of moving the button, try
margin-top: 50px; for example in the css of btn. This way, the button is moved 50pixels to the bottom. Margin-left moves the button to right, ...
if you are trying to move the button down then you need to first put it in a wrapper
if not try this .
body {
background: url('images/prices.jpg');
min-height: 100%;
height: 100%;
}
#navigation {
position:relative;
display:block;
margin:40px 0px 0px 0px;
padding:0px;
width:auto;
height:auto;
}
#navigation ul {
display:block;
position:relative;
margin:auto;
padding:0px;
}
#navigation ul li {
list-style:none;
}
#btn {
color: #FAF3BC;
background: #4FB69F url('images/texture.png') no-repeat right bottom;
padding: 15px 30px;
margin: 150px 0px;
border-top: 5px;
border-radius: 25px;
text-decoration: none;
text-transform: uppercase;
}
and about your background you can try one thing. Have a looping background texture similar to the one you have right now with background-repeat:repeat; and then put the main background image above it with z-index and centered if required. Just to give you a simple example
body {
background-image:url('images/loop.jpg);
background-repeat:repeat;
}
#backgroundimg {
background-image:url('images/prices.jpg);
background-repeat:no-repeat;
display:block;
position:relative;
width:980px;
height:700px;
margin:auto;
padding:0px;
}
hope this helps :)

Adaptive thumbnail div which responsive to screen size

I have a list of thumbnail images which when you resize the browser screen they all adapt nicely and keep the same height and width.
I need to add in a thumbnail for when there is no image, with a centerd icon, however when i resize the browser the div doesnt expand the same way as the images.
This is designed for mobile screens, but i would like it to have the same behavious as the images.
What am i missing in the code, im guessings its a css issue to do with height or margin / percentage values?
I have a demo with all the code i have done: -
http://jsfiddle.net/zM5SG/1/
.gallery li a.addImage {
display: block;
margin: 7px 5px 0 5px;
border: 1px dotted #aaa;
background-color: #ddd;
min-height: 58px;
}
.test{
background: url("http://icons.iconarchive.com/icons/custom-icon- design/mini/24/Delete-icon.png") no-repeat scroll /*1px -109px*/ center transparent;
display: block; width:24px; height:24px; text-align:center;
margin: 0 auto;
margin-top: 15%; margin-bottom: 15%;
}
Any help would be great thanks.
I know it's not the most elegant way, but couldn't you just replace the "empty space" with an image that looks blank? so it would resize the same as the other images?
Test Page
I suggested to you to use <img> tag instead of <span class="test">, and I used transform css for scaling the image.
also min-height deleted for perfect working in all scales.
.test {
-webkit-transform: scale(0.2);
-moz-transform: scale(0.2);
-o-transform: scale(0.2);
transform: scale(0.2);
}
For the class test instead of width:24px give width:inherit. So the new style will be
.test{
background: url("http://icons.iconarchive.com/icons/custom-icon- design/mini/24/Delete-icon.png") no-repeat scroll /*1px -109px*/ center transparent;
display: block;
width:inherit; height:24px; text-align:center;
margin: 0 auto;
margin-top: 15%;
margin-bottom: 15%;
}
Hope this helps.

Looking to have a <hr> and <h3> together

Like the example above. I've found some helpful script with the a small img which I do like however I don't know how to get the padding about the title so the line doesn't go straight through.
h3.line {
background-attachment: scroll;
background-clip: border-box;
background-color: transparent;
background-image: url(../images/line.jpg);
background-origin: padding-box;
background-position: center;
background-repeat: repeat-x;
background-size: auto auto;
display: block;
margin-bottom: 20px;
}
Which shows this.
Any suggestion or ideas?
You can have a 1px dot image which you can place as a background on the H3. Then have a span element in between which have a background on.
CSS:
h3 {
background: url(images/dot.png) left center repeat-x;
padding: 10px;
text-align: center;
}
h3 span { background: #fff; display: inline-block; padding: 10px 15px; }
HTML:
<h3><span>About</span></h3>
You can put a <span> for example in your <h3> and make it have the same background as your <h3> but without the line so the <span> effectively overlaps the <h3>.
You can say this to your span:
span {
display: block;
margin-left: auto;
margin-right: auto;
}
to make it center. You can add width and height to it too. line-height helps place your text to the middle vertically.
If you want to spare images than you can use text-decoration: line-through; to draw a line through your text.
Here is a solution using the CSS border property instead of an image.
the html:
<h2>
<span>This is a test</span>
<div></div>
</h2>
And here is the CSS:
h2 {
text-align:center;
background-color:#EFEFEF;
line-height:26px;
position:relative;
}
span {
background-color:#EFEFEF;
padding-right:5px;
padding-left:5px;
position:relative;
z-index:2;
}
h2 > div {
border-bottom:1px solid grey;
position:relative;
z-index:1;
top:-13px; /* half the line-height of the containing element */
}
A fiddle Demonstration
The <div> is placed inside the heading element, and positioned half-way up by settings its top position to one-half the height of the heading element, which is the headings line-height. z-index is used on the span and div so that the span gets a higher stack order than the div and obscures the (border) line where there is overlap.
I just stumbled upon another way of achieving this.
h1
{
position: relative;
padding: 0 26%;
}
h1:before,
h1:after
{
width: 25%;
background-color: rgba( 0, 0, 0, .5 );
content: '';
position: absolute;
top: 0;
bottom: 0;
}
Taken from: http://osvaldas.info/blog/background-independent-css-bars

Changing the top-margin on one image is shifting all images within the same container

I have a few Links/images sitting side by side in a container.
The container has its overflow property set to overflow: hidden and the images are 'sunken' into the container using margin-top: -50px;.
When the user hovers over the link I want the image to slide down out of the container and when the user hovers out the image jumps back up.
Here is a demo of what I have currently.
Here is my css ( I will post it all in case there are problems somewhere else that is causing this)
html, body {
width:100%;
height: 100%;
margin:0;
padding:0;
}
#w {
display:table;
width: 100%;
height: 100%;
}
#iw {
display:table-cell;
text-align:center;
vertical-align:middle;
width: 100%;
}
#iiw {
border-top: 1px solid #000;
height: 125px;
overflow: hidden;
}
#iiw a {
margin-left: 8px;
margin-right: 8px;
}
#iiw a img {
margin-top: -50px;
height: 100px;
-moz-box-shadow:0 0.8em 1em #444;
-webkit-box-shadow:0 0.8em 1em #444;
-o-box-shadow:0 0.8em 1em #444;
box-shadow:0 0.8em 1em #444;
-moz-border-radius:0 0 10px 20px;
-webkit-border-radius:0 0 10px 20px;
-o-border-radius:0 0 10px 20px;
border-radius: 0 0 10px 20px;
}
and html HTML markup is
<div id="w">
<div id="iw">
<div id="iiw">
<a href="#">
<img src="http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png" />
</a>
<a href="#">
<img src="http://programmers.stackexchange.com/content/programmers/img/apple-touch-icon.png" />
</a>
</div>
</div>
</div>
I'm using JQuery right now to do the hover events (for ease of use), however the final product will have no JQuery (so don't comment on the JQuery code)
Edit I realize I left that code out.. oops.
very simple stuff. just using it to swap the margin-top property
$("a").hover(function() {
$(this).children().css("margin-top", "-2px");
}, function() {
$(this).children().css("margin-top", "-50px");
});
#iiw a {
display: block;
float: left;
}
Them a tags need to be block level.
It appears that elements that share the same line will align themselves with the lowest element in that line. When you set the top margin of an image to be much lower than the rest, the other images will drop down so their bottom edges align with it.
To avoid this behavior, try adding vertical-align:top; to your #iiw a img block. I've applied the change to your example here.