so i have a situation where i want text to appear over an image using visibility:hidden/visible and also playing with opacity. i cannot do it for some reason. Note that this is in a list because i have other images displayed in the same list but here i am only showing one. below is the html:
<ul>
<li>
<a class="pic" href="#">
<img alt="" src="/servlet/servlet.FileDownload?file=00PU00000096kH2MAI" style="width: 300px; height: 160px;" />
</a>
<div class="hovertext"> my hover text</div>
</li>
</ul>
and the css is here:
#gallery ul{
margin:0;
padding:0;
list-style:none;
}
#gallery li{
display:block;
float:left;
width:310px;
height:170px;
margin:0 15px 15px 0;
}
#gallery li a{
display:block;
float:left;
width:300px;
height:160px;
margin:0;
padding:4px;
}
#gallery li a:hover {
color:#FFFFFF;
opacity:0.6;
background-color:#666666;
}
#gallery li a:hover .hovertext{
visibility:visible;
}
.hovertext{ width:300px; height:85px;
background-color:#666666;
opacity:0;
visibility:hidden;
display:block;
text-align:justify;
color:#000000; font-size:20px;
}
all this does is allow me to see that the image is opaque and i can see that the div is in the background but i just cannot bring it forward to display in front of the opaque text. Any help would be greatly appreciated.
Look at the following code.
#gallery li a:hover .hovertext{
visibility:visible;
}
The above code will look the child element of hovertext when you hover the link. In your case, it is siblings element. So update your CSS like below.
#gallery li a:hover + .hovertext{
visibility:visible;
}
Also you have added opacity:0 for hovertext class. I think there is no need for that one. Because already you have visibility:hidden for the same class. So update your CSS like below.
.hovertext{ width:300px; height:85px;
background-color:#666666;
visibility:hidden;
display:block;
text-align:justify;
color:#000000; font-size:20px;
}
DEMO
Related
i have a problem fitting text into blocks (dropdown menu) in CSS.
The code is in Serbian language, but if needed i can translate it to english.
Ok, so i have "Ponuda usluga", when i mouse over that, i get dropdown menu with "Lov" , "Obuka Pasa", "Ribolov" and "Obezbedjivanje potrebne dokumentacije", but the problem is the last one does not fit and proceedes to go under in next line, like shown on screenshot1 here https://ibb.co/YbTytJw (NOTE: at the screenshot i was hovering over "ribolov", thats why its orange).
I would like it to be like this screnshot2 https://ibb.co/dW65Tyx.
Same problem when i hover over "Lov" (that opens a new dropdown menu with 2 options there) like shown on screenshot3 https://ibb.co/0ZKxVWj (Note: I added >> to point out that there is another dropdown menu, and again, i was hovering over "lov", so thats why its orange). Same as the first problem, i need it to say "lov na sitnu divljac" and underneath "lov na krupnu divljac", instead it says "lov na sitnu", "lov na krupnu" and underneath "divljac". I need it to be like screenshot4 https://ibb.co/8zspMY0.
<style>
*{
padding:0;
margin:0;
box-sizing:border-box;
}
html{
height:100%;
}
.wrapper{
min-height:100%;
width:100%;
position:relative;
}
body{
height:100%;
background:#ddd;
}
h2{
padding:50px;
background-color:#161B21;
color:#f0f1f5;
font-family: big john;
text-align:center;
font-size:30pt;
letter-spacing:15px;
}
.navigationDesktop{
background-color:#161B21;
}
nav{
height:40px;
width:700px;
display:block;
margin:0 auto;
text-align:center;
text-transform: uppercase;
}
nav a{
display:block;
text-decoration:none;
font-family:monospace;
font-weight:bold;
font-family:13pt;
color:white;
}
nav a:hover{
background-color:#F4A950;
color:#f0f1f5;
}
nav ul{
list-style:none;
}
nav ul li{
float:left;
width:140px;
height:40px;
line-height:40px;
background-color:#161B21;
list-style-type: none;
}
nav ul ul li{
position:relative;
display:none;
}
nav ul ul ul{
display:none;
}
nav ul li:hover ul li{
display:block;
animation: navmenu 500ms forwards;
}
#keyframes navmenu{
0%{
opacity:0;
top:5px;
}
100%{
opacity:1;
top:0px;
}
}
nav ul ul li:hover ul{
display:block;
position:absolute;
width:140px;
left:140px;
top:0px;
}
</style>
Here is the pastebin of the HTML https://pastebin.com/MLweR454
And here is the pastebin of the CSS https://pastebin.com/mtszKhNu
That is happening because you are trying to set each nav link block size by using line-height:40px, that creates 40px of space between each line of text. What you want do to is set your nav a to line-height:1.1;, no px, and make the size of the link block be based of the amount of text and padding, by adding padding: 15px 0;
I´m modifying an HTML/CSS template. Also, I´m using a premade Image Gallery, which is lengthy (these two have been developed by different designers). I don´t know why the Image Gallery exceeds it´s own div, and overlaps with div of footer. I´m sure that there is something wrong with the image gallery, cause if I put a large picture instead, it wont exceed the footer. How can I fix this issue and limit the image gallery to the main body?
Following is HTML code of the image gallery:
<div class="photo">
<ul class="topic">
<li><a class="set" href="#Birds">Birds<!--[if gte IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul style="left: 0; top: 31px; height: 750px">
<li><img src="http://www.cssplay.co.uk/menu/lbox/bird1.jpg" alt="" title="" /></li>
<li><img src="lbox/bird2.jpg" alt="" title="" /></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>
<br class="clear" />
</div>
Following is Image Gallery´s CSS:
<style type="text/css">
/* common styling */
a {color:#000;}
a:hover {text-decoration:none;}
a:visited {color:#000;}
/* slides styling */
.photo {width:635px; text-align:left; position:relative; margin:0 auto;}
.photo ul.topic {padding:0; margin:0; list-style:none; width:635px; height:auto; position:relative; z-index:10;}
.photo ul.topic li {display:block; width:125px; height:31px; float:left;}
.photo ul.topic li a.set {display:block; font-size:11px; width:124px; height:30px; text-align:center; line-height:30px; color:#000; text-decoration:none; border:1px solid #fff; border-width:1px 1px 0 0; background:#ccc; font-family:verdana, arial, sans-serif;}
.photo ul.topic li a ul,
.photo ul.topic li ul
{display:none;}
.photo ul.topic li.active a
{color:#000; background:#bbb;}
.photo ul.topic li a:hover,
.photo ul.topic li:hover a
{color:#fff; background:#aaa;}
.photo ul.topic li.active ul
{display:block; position:absolute; left:0; top:31px; list-style:none; padding:0; margin:0; height:375px; background:#ddd; width:464px; padding:40px 60px; border:20px solid #bbb; z-index:1;}
.photo ul.topic li a:hover ul,
.photo ul.topic li:hover ul
{display:block; position:absolute; left:0; top:31px; list-style:none; padding:0; margin:0; height:375px; background:#ddd; width:464px; padding:40px 60px; border:20px solid #aaa; z-index:100;}
.photo ul.topic li ul li
{display:inline; width:112px; height:87px; float:left; border:1px solid #fff; margin:1px;}
.photo ul.topic li ul li a
{display:block; width:110px; height:85px; cursor:default; float:left; text-decoration:none; background:#444; border:1px solid #888;}
.photo ul.topic li ul li a img
{display:block; width:100px; height:75px; border:5px solid #eee;}
.photo ul.topic li a:hover ul li a:hover,
.photo ul.topic li:hover ul li a:hover
{white-space:normal; position:relative;}
.photo ul.topic li a:hover ul li a:hover img,
.photo ul.topic li:hover ul li a:hover img
{position:absolute; left:-50px; top:-32px; width:200px; height:150px; border-color:#fff;}
</style>
jsfiddle for Image Gallery:
https://jsfiddle.net/dexoey/opzwksmz/
Following is my footer´s code:
<div class="wrapper col7">
<div id="copyright">
<div class="list-group" style="float:left">
<a class="list-group-item" href="" target="_blank"><i class="fa fa-linkedin-square fa-5x fa-cog-li"></i></a>
</div>
<br/> <p>Desgined by </p>
<div class="clear"></div>
</div>
</div>
And following screenshot explains the problem (I havent put full code of my page because its too messy):
I am not sure this is what you want, But try this..
I think you can overcome this problem by using overflow:scroll, so it wont overlap. As per your above fiddle, the image overlaps another image, for that you can use overflow: hidden, like this...
a:hover {text-decoration:none; overflow:hidden;}
i have edited your fiddle, check it once -> https://jsfiddle.net/opzwksmz/3/
check this updated fiddle-> https://jsfiddle.net/opzwksmz/5/
go for flowers tab , i have added overflow:scroll , so all images will sit inside your div itself.
As per Q1. It adds scroll bar, so it occupies some space which makes your div ti shrink a little, so you can increase the width of
.photo ul.topic li.active ul
{display:block; position:absolute; left:0; top:31px; list-style:none; padding:0; margin:0; height:375px; background:#ddd; width:484px; padding:40px 60px; border:20px solid #bbb; z-index:1;}
.photo ul.topic li a:hover ul,
.photo ul.topic li:hover ul
{display:block; position:absolute; left:0; top:31px; list-style:none; padding:0; margin:0; height:375px; background:#ddd; width:484px; padding:40px 60px; border:20px solid #aaa; z-index:100;}
i have changed it from 464 to 484 as shown above.
Q2. Screen size is based on your div width and height, its a good practice to use % instead of pixel. I have changed width pixel to 70% check in below fiddle.
Q3. If you increase the size manually of any component which is inside div, the div size also expands, if the div size is small, to overcome this better you use something like..
max-width: 100%;
height: auto;
If the max-width property is set to 100%, the image will scale down if it has to, but never scale up to be larger than its original size.
As you said using % will be good idea, so better you set you page according to % instead of pixel, easy to change, and it wont exceed its size also if you try to increase the size manually.
CHECK THIS FIDDLE https://jsfiddle.net/opzwksmz/8/
I am not sure , but this may work for you..
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
if ( $(window).width() > 739) {
//nothing happens
}
else {
//write an error message like, alert("screen size is less");
}
See more at: http://www.coalmarch.com/blog/how-to-execute-javascript-based-on-screen-size-using-jquery#sthash.zJp7JwAt.dpuf
Working to add a simple image description/text-box appear over an image when it's hovered.
When I don't worry about the hover and just switch the visibility to visible on my span, it's exactly what I'm looking for.
I would've thought that simply using visibility:hidden and visibility:visible on the hover state would've worked, but it's not coming up.
I think I'm having a positioning problem, but I'm clearly overlooking something and have probably been staring at this for too long.
Abridged HTML:
<div id="gallery">
<ul>
<li>
<a href="full-size-image.jpg"><img src="tumbnail.jpg"/>
<span class="image-caption">Image Caption Text</span></a>
</li>
<li>
<a href="full-size-image.jpg"><img src="tumbnail.jpg"/>
<span class="image-caption">Image Caption Text</span></a>
</li>
</ul>
</div>
Abridged CSS:
#gallery {
width:100%;
margin:auto;
}
#gallery ul {
list-style:none;
margin:0;
padding:0;
}
#gallery ul li {
display:inline;
position:relative;
margin:0;
padding:0;
}
#gallery ul li span {
visibility:hidden;
position:absolute;
width:100%;
left:0;
bottom:0px;
z-index:3;
background:rgba(0,0,0,.6);
color:#FFF;
text-align:center;
}
#gallery ul li span:hover {
visibility: visible;
}
call the :hover on the li instead of the span and target the span
#gallery ul li:hover span {
visibility:visible;
}
FIDDLE
Also remove the ; on that hover statement:
#gallery ul li span:hover; <---- {
I am new to web development and I building my first website. I want to create a header that has an image in the center and the nav menu surrounding it.
Here is the code I'm working with:
HTML:
</head>
<body>
<div id ="header">
<div id="nav">
<ul>
<li>About</li>
<li>Philanthropy</li>
<li><img src="http://i.imgur.com/cosDXx1.png"/></li>
<li>Why Join?</li>
<li>Contact</li>
</ul>
</div>
</div>
</body
>
CSS:
body {
margin:0px;
padding:0px;
}
#header{
width:100%;
height:110px;
background-color:black;
}
#nav ul{
list-style-type:none;
font-family:"Slabo 13px",serif;
float:center;
}
#nav ul li{
padding:10px;
display:inline;
margin-left:60px;
margin-bottom:20px;
}
#nav ul li a{
text-decoration:none;
color:#006600;
}
#nav ul li a:hover{
color:#CC0000;
}
JSfiddle link:
http://jsfiddle.net/5g6sm01q/
On my screen it is in a line but when I shrink it (and in the jsfiddle example) it is not. Please any tips or help with this problem would appreciated.
Convert all the pixel values into % or atleast the padding and the left and right margins, and see the change..I've just edited your fiddle a little bit..
see this http://jsfiddle.net/5g6sm01q/2/
Chnge the css like this
body {
margin:0px;
padding:0px;
}
#header{
width:100%;
height:110px;
background-color:black;
}
#nav ul{
list-style-type:none;
font-family:"Slabo 13px",serif;
float:center;
}
#nav ul li{
padding:0.5%;
display:inline;
margin-left:2%;
margin-bottom:20px;
}
#nav ul li a{
text-decoration:none;
color:#006600;
}
#nav ul li a:hover{
color:#CC0000;
}
UPDATE
As #Krodmannix mentioned in his comment,there is a way in CSS to dictate how to format the page based on different screen sizes using media queries.It makes it very easy to adapt your site to mobile screens without any page redirection
hi i am working on a site layout , because of my problem and for some other reasons like that it doesn't matter to me if i just can use the layout on my own as well cause i made it.
but the problem is that the pulldown menu isn't working as it is mend to be.
i share with you the code:
<html>
<head>
<style>
body{
background:linear-gradient(to bottom right,#013,#c0c);
color:#930;
}
#nav{
margin-left:auto;
margin-right:auto;
margin-top:40px;
maring-bottom:10px;
color:#930;
background-color:#cb6;
border:2px solid #930;
border-radius:13px;
-webkit-border-radius:13px;
-moz-border-radius:13px;
text-align:center;
float:center;
width:750px;
height:40px;
}
#main{
margin-left:auto;
margin-right:auto;
margin-top:auto;
maring-bottom:auto;
color:#930;
background-color:#cb6;
border:2px solid #930;
border-radius:13px;
-webkit-border-radius:13px;
-moz-border-radius:13px;
text-align:center;
float:center;
width:750px;
height:500px;
}
#nav ul{
list-style:none;
margin:0 auto;
}
#nav li{
position:relative;
float:left;
display:inline;
}
#nav a{
text-decoration:none;
color:#930;
padding:10px 25px;
height:20px;
display:inline-block;
}
#nav a:hover{
text-decoration:none;
color:#fff;
background-color:#930;
padding:10px 25px;
height:20px;
display:inline-block;
}
#pull li ul{
display:none;
color:#930;
text-align:center;
position:absolute;
}
#pull li:hover ul{
display:block;
color:#930;
text-align:center;
position:absolute;
}
#pull li ul a{
display:block;
min-width:80px;
width:auto;
height:25px;
color:#fff;
padding:0px 5px;
text-align:center;
border:2px solid #930;
background-color:#cb6;
}
#pull li ul a:hover{
display:block;
min-width:80px;
width:auto;
height:25px;
color:#fff;
padding:0px 5px;
text-align:center;
border:2px solid #fff;
background-color:#930;
}
</style>
</head>
<body>
<div id="nav">
<ul id="pull">
<li><b>home</b></li>  
<li><b>page 1 ▼</b>
<ul>
<li><b>page 2</b><li>
<li><b>page 3</b><li>
</ul>
</li>
</ul>
</div>
<br><br>
<div id="main">
de content komt nog
</div>
</body>
</html>
also the online lay-out is see-able for eyes at www.elderpact.tk
the menu bar and everything need to stay like they are
but the drop down menu has to lower the content box if it is opened.
now it goes right trough the content.
also i would like to display the drop down menu direct under the drop down menu opener
(page 1).
could someone please help me?
the risk with create you own dropdown is not work in all browsers. The best solution for this problem is use Bootstrap Twitter. Bootstrap DropDown
Here's a fiddle with the menu the way I think you want it: http://jsfiddle.net/TPLJ8/1/
You basically need to remove the margin and padding from the ul and li elements at the top of your CSS (resets), like this:
ul, li {margin:0; padding:0;}
This will help you start with a clean slate. I also cleaned up your CSS as you don't need to declare the same styling on hovers if that style stays the same.
Your HTML also needed some work. You were missing closing </li> tags and had a bunch of unnecessary <br /> tags.