Using a:hover to display a div - html

I'm trying to display a div class but it won't show. I'm not sure what I'm doing wrong. Here's what I'm doing.
So, I have a table. The point of this is to hover on one of the tables contents and show a display with more details of the link hovered. In this case "Hover Me!"
file.html
<div id="bigBody">
<table class="tableClass">
<tr>
<td>
<a class="hoverHereToPopUp">Hover Me! </a>
</td>
</tr>
<table> /*Just to keep the table short */
<div class="hoverPopUp">
<p>This is a Hover</p>
</div> /*EO HoverPopUp */
</div> /*EO bigBody */
style.css
div.hoverPopUp {
display:none;
width:auto;
height:auto;
border:dotted purple;
}
a.hoverHereToPopUp:hover + div.hoverPopUp {
display: block;
}
I added some styles to attempt to debug my issue:
a.hoverHereToPopUp {
color:red;
border:green dotted;
}
a.hoverHereToPopUp:hover {
color:white;
border:yellow dashed;
}
The hover is changing the color but the div isn't showing.
What am I doing wrong?
Viewing this on chrome.
The Hover is inside a table. which is inside a DisplayDiv, in that container there's another divContainer for the popUp. So, BIG box has 2 Small Boxes, one with the Hover(a table) and another(a div) for the Pop Up. Is this the problem????

If I understand correctly, the hidden div needs to be inside the div which gets the hover.
Something like this:
<div>
Hover over me
<p>This is hidden</p>
</div>
See: http://jsfiddle.net/webbymatt/URwNz/
The current way you have your markup means this will not work with CSS. What you need to do is put the hidden area INSIDE the hoverable div. Like this:
<div id="bigBody">
<table class="tableClass">
<tr>
<td>
<a class="hoverHereToPopUp">
Hover Me!
<p>This is a Hover</p>
</a>
</td>
</tr>
</table> /*Just to keep the table short */
</div>
Then with your CSS
.hoverHereToPopUp p {
display: none;
}
.hoverHereToPopUp:hover p {
display: block;
}

From what #Slevin pointed out, the code provided is working fine. I would recommend look at the rest of your code of inspecting the live code to see if you have the element you're trying to show hidden elsewhere.

Related

How to apply `display:none;` to everything except an `<td class="cc">text</td>`?

So I tried:
body :not(.cc) { display: none; }
and various other things I found on here. (!important, * instead of body, ...)
I even tried it for a span-element with that class instead of the td-element.
Nothing worked.
<html>
<body>
<table><tr><td class="cc">text</td></tr></table>
Other text to not ne shown.
</body>
</html>
Edit: Please excuse I first put a misleading html-snippet here first. I removed that.
Edit2: I added "Other text to not be shown."
You will need something like this
body *:not(table):not(tr):not(td):not(tbody),
td:not(.cc) {
display: none;
}
<table>
<tr>
<td>hide</td>
</tr>
<tr>
<td class="cc">show</td>
</tr>
<div>Other text to not be shown.</div>
</table>
Basically, hide everything in body except table elements, then the second rule hides td that is not .cc class. I added tbody because some browsers will automatically add this to your tables. The basic rule of thumb is, you cannot hide any parents that contains the element you want to show.
As far as the text is concerned, you need to wrap the text in an element so you can target it with css. Currently it is wrapped by the body tag and you cannot hide the body tag or else nothing will be shown.
You can refer to this question for the text node styling Is there a CSS selector for text nodes?
You cant show .cc class because its inside hidden body! u can do this if u want
p:not(.cc) {
display: none;
}
<p>text get's hidden</p>
<p class="cc">text doesn't get hidden</p>
<p>
hello world!
</p>
Why don't you simply first set none for everything and the block for your class:
body { display : none ; }
.cc { display : block; }

Show elements on hover with CSS

I want to show 2 elements (one div, inside it one buttom) when I hover an image. I got some problems: It didn't works!
My HTML code:
<div class="discord-container">
<center>
<img src="https://i.imgur.com/7K3OLPH.png", class="discord-image", width="75"/>
<div class="discord-poupup" id="poupup-element">
<button onClick="discord.logout()" class="logout-button" id="poupup-element">LOGOUT</button>
</div>
</center>
</div>
On CSS:
.discord-image {
border: solid #7289DA;
border-radius: 100px;
}
img.discord-image:hover + div#poupup-element:hover {
display:block;
}
#poupup-element{
display: none;
}
The 'discord-poupup' class on div just change background colors and positions, it don't touch on display.
Well, I want to show everything with id 'poupup-element' when I hover the image with class 'discord-image' (and preferably keep it showing while the mouse cursor is hoving it AND its already active). I tried lots of things, but nothing works :c Can someone help-me?
(I'm also using Shiny (from R lang). If there is an easier way to do what I want please tell-me)
Like others already mentioned, 'id' should be unique. You could try giving your div and button a class called "poupup-element".
Also, you have commas in your img tag that should not be there.
HTML
<div class="discord-container">
<center>
<img src="https://i.imgur.com/7K3OLPH.png" class="discord-image" width="75"/>
<div class="discord-poupup poupup-element">
<button onClick="discord.logout()" class="logout-button poupup-element">LOGOUT</button>
</div>
</center>
</div>
.discord-image {
border: solid #7289DA;
border-radius: 100px;
}
.poupup-element{
display: none;
}
img.discord-image:hover .poupup-element {
display:block;
}
I guess there was an issue with your HTML. You should not have two same ID's. Also you should not put commas in your HTML tags.
here's the solution
css:
#poupup-element{
display:none;
}
.discord-image:hover + #poupup-element{
display:block;
}
Edit:
html
<div class="discord-container">
<center>
<img src="https://i.imgur.com/7K3OLPH.png" class="discord-image" width="75" />
<div class="discord-poupup" id="poupup-element">
<button onClick="discord.logout()" class="logout-button" >LOGOUT</button>
</div>
</center>
</div>

How do I place multiple divs that contain text and a floated image so they flow down the page one at a time and don't overlap?

I have a custom helper which returns a html string. Which outputs the follow html code:
<div>
<div class='floatRight'>
<img height='300' src='{0}' />
</div>
<div class='clearFloat'>
<h4>{1}</h4>
<p>{2}</p>
</div>
</div>
When this is placed inside a foreach loop I want it to show the heading and paragraph text with the image inline to the right of it. If the height of the image is bigger than the heading and text then I want the next heading and text to appear below the the line of the previous image. However the result I get is a Left-Down diagonal positioning of images. I'm sure this is an easy fix but nothing seems to be working. I'm not sure if this a float problem or a div problem since the images flow into other divs. Basically I want the very outer div to expand with the greater of: the height of the image, or text so that the next div will be placed under that and not just under the text part.
For a more visual example I am looking for something will replicate this:
<table>
<tr>
<td>
<h4>Title</h4>
<p>Text Text Text Text Text </p>
</td>
<td><img width="300" height=300" /></td>
</tr>
</table>
I was trying to avoid to avoid tables but maybe floating divs are just as bad.
From your description it sounds like your problem is that you were attempting to use floats.
Solution below. Let me know if I’m misunderstanding what you’re trying to do.
/* Demo Styles
-------------------------------- */
img {
width: 300px;
height: 300px;
}
li:nth-child(1) img { background:dodgerblue }
li:nth-child(2) img { background:gold }
li:nth-child(3) img { background:red }
/* Reset Default Browser Styles
-------------------------------- */
* { margin:0; padding:0 }
li {
list-style: none;
}
/* Layout
-------------------------------- */
/* All direct children of the list element */
li > * {
display: inline-block;
vertical-align: top;
}
<li>
<div>
<h1>Your title</h1>
<p>The description of descriptions of descriptions</p>
</div>
<img>
</li>
<li>
<div>
<h1>Your title</h1>
<p>The description of descriptions of descriptions</p>
</div>
<img>
</li>
<li>
<div>
<h1>Your title</h1>
<p>The description of descriptions of descriptions</p>
</div>
<img>
</li>
Editable demo: http://jsbin.com/puveba/2

HTML/CSS <div> background

How do you set a background on a div? I have a block looking like this:`
<div class="span4">
<font color="000000">
<h4 class="text-center">This is the title</h4>
<p>This is my text</p>
<a href="#" class="btn btn-success">
<i class="icon-star icon-white"></i> This is my button</a>
</font>
</div>
I want to make this whole block have a background image, but when I try (I've tried 6 different methods already), It either doesn't work at all, doesn't fill the whole box, or fills the whole page.
After using JoshC's CSS related answer, I got this problem. In the image you can see my background, but it doesn't stretch across the whole area I want it to. The side bar, as far across as the left edge of the blue highlight on "Home", is meant to be a different image, (not set up yet) and the rest would be the displayed image.
This is the image
Another thing I'd like is a background applied to multiple divs, but not all, however that's optional...
Any help is much appreciated.
Apply a background-image like this:
.span4 {
background-image: url(http://example.com/image.png);
}
jsFiddle demo
or.. style within the HTML like this:
<div class="span4" style="background-image: url(http://example.com/image.png);"></div>
jsFiddle demo
You obviously have to change the URL to an image that exists.
See the specs on the background property here: https://developer.mozilla.org/en-US/docs/Web/CSS/background-image
.span4
{
background-image:url('your image path');/* by this image set*/
background-color:#cccccc;/* and can use color*/
}
You can give somethinglike this: <div class="span4" style="background:url(../Pictures/website.png) no-repeat fixed;">
We are going to warp your head for a second. Divs are like boxes that exist with no border, no per-defined styles other than 100% width.
You are combining table-line HTML3 standard structure to the nature of a HTML5 div. In the newest code does not contain such attributes like table cells did in the past.
We would accomplish this today through CSS bound to ID's or classes to call those elements that exist within the DOM.
css
<style type="text/css">
.span4{ background-image:url('images/myimage.jpg');
background-repeat:no-repeat;
width:100px; height:100px; }
.span h4{ color:#000; text-align:center; }
.span4 p{ font-weight:bold; /*or whatever*/}
.span4 a{ font-style:italic; color:#0f0; }
.span4 a:hover{}
.span4 a:active{}
.span4 a:visited{}
.span4 a.btn{ color:blue; }
.span4 a.btn-success{ color:green; }
.span4 a.btn.btn-success
.icon-star:before{ content: '* '; }
.icon-white:before{ color:#fff; }
</style>
html
<div class="span4">
<h4>This is the title</h4>
<p>This is my text</p>
This is my button
</div>`

div inline tag for Addthis code

I have such a table:
<table>
<tr>
<td>
My text which consists of three lines.
Where I write some tips tricks and some news.
Which is important.
<div style="display: inline-block" class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
</div>
<td>
</tr>
</table>​
This code puts two buttons to the end of cell, but one of them is in up and other one is down.
If I change to this, buttons are on same line but buttons are put in the beginning of third lines. But I need it to appear in the end of third line. How can I fix this?
<div style="display: inline" class="addthis_toolbox addthis_default_style ">
Edit: this is addthis's script: http://s7.addthis.com/js/250/addthis_widget.js
It includes this css: http://s7.addthis.com/static/r07/counter002.css
Css has following code inside:
.addthis_default_style .addthis_counter {
display:block;
float:left;
}
Edit2: I updated to "display: inline; float:right;". Result is this:
Try adding the float:right; style in the addthis_toolbox class.
This fiddle shows what applying this style accomplishes.
EDIT
Since you were using the AddThis widget I updated the fiddle to use that same widget and added the following CSS style change:
.addthis_toolbox {
float: right;
width: 50px;
}