hover image and text change - css

what i'm looking for is a way that when an image is hovered the text, that is over it, changes. I've searched the site for while all the solutions don't seem to work for me.
Here's my code.
<div class="four columns full-height">
<div class="projects">Collectif Neuf</div>
<img class="vertical" src="images/projects/c9.jpg">
</div>
i've also tried this : CSS image hover change color of text
it only works if the img is over my .projects div. But my .projects div needs to be over the img for it to display properly.
Thanx for your help.
EDIT
I've just realize that i didn't explain well what i am looking for. By text change i meant that when the image is being hover the link will be underline. Now the link only gets underline if it's being hover.
Really sorry for that.

Without jquery:
<script>
function domover(el) {
el.parentNode.parentNode.firstChild.firstChild.style. = 'Hi!';
el.parentNode.parentNode.firstChild.firstChild.style.textDecoration = 'underline';
}
function domout(el) {
el.parentNode.parentNode.firstChild.firstChild.innerHTML = 'Bye';
el.parentNode.parentNode.firstChild.firstChild.style.textDecoration = 'none';
}
</script>
<div class="four columns full-height"><div class="projects">Hi</div>
<img class="vertical" src="http://i.imgur.com/l5WLB.jpg" onmouseover="domover(this)" onmouseout="domout(this)">
</div>
Test: http://pastehtml.com/view/c6kbpxrzp.html
Notice that, for this to work, there must be no spaces (nor newlines) between the first elements.

Related

Remove white bar things from my dropdown box / how to replace an empty div tag in an boolen queary?

What is this white stuff around my "open" drown down menu and how do I get rid of it?
I am using DropdownButton from react bootstrap
I already have tried to change the css
.Navigation-Bar-Dropdown-Container{
color: $NormalFontColour ;
background-color: $TopBarBackgroundColour;
border:none;
}
On a side question I also have the following code:
{values.map((newItem) => (
<div key={newItem.id}>
{newItem.parentId == item.id? <a className="Navigation-Bar-Sub-Menu-Items-Container" href="#">
<div className="Sub-Menu-Sub-Menu-Titles">{newItem.title}</div>
<div className="Sub-Menu-Sub-Menu-Shortcuts">{newItem.shortcutCommand}</div>
</a>:<div></div>}
is there something I can replace ":<div></div>" with? As it results in loads of empty div tags on my page?
You can set the background of the parent div to be the same as your child div, i.e.
<div key={newItem.id} className="Navigation-Bar-Dropdown-Container"> .... </div>

CSS Hover Changing All Of Class

I know this is a pretty newb question, but I cannot seem to find an answer to it via Googling. I am using the Chrome plugin StyleBot to alter the CSS of an internal tool used by the company I work for. So I only have access to editing CSS.
I am attempting to make it so when I hover a specific element on the page, it changes the background color to highlight the information. What I need to do is make it so that ONLY the .row element I am hovering changes. Currently the way I am doing this is changing ALL .row elements. Basically, with some back-end code they are generating a list, each item in the list is coded with this:
<span class="row">
<div class="boxy txtleft"><span title="Agent"></span></div>
<div class="boxy"><span title="Status"></span></div>
<div class="boxy txtright"><span title="Last Call"></span></div>
</span>
So in the live environment it looks some what like this and keeps repeating:
<span class="row">
<div class="boxy txtleft"><span title="Agent"></span></div>
<div class="boxy"><span title="Status"></span></div>
<div class="boxy txtright"><span title="Last Call"></span></div>
</span>
<span class="row">
<div class="boxy txtleft"><span title="Agent"></span></div>
<div class="boxy"><span title="Status"></span></div>
<div class="boxy txtright"><span title="Last Call"></span></div>
</span>
<span class="row">
<div class="boxy txtleft"><span title="Agent"></span></div>
<div class="boxy"><span title="Status"></span></div>
<div class="boxy txtright"><span title="Last Call"></span></div>
</span>
The CSS I am using to try and highlight a row when I hover it:
.row:hover {
background-color: red;
}
I know why this would alter all the .row elements, but I cannot figure out how to make it alter ONLY the one my mouse is over. Any help would be appreciated!
maybe you mean each single(descendant) element in row:
.row> *:hover {
background-color: red;
}
http://jsfiddle.net/maio/tyLayh3c/1/
Your current code does not highlight all the elements when one is hovered, it works like you think. Although, with the code you gave none of them will highlight since there is no size to the '.row' span's, they don't have any width or height for a background. So the following code worked for me:
.row span:hover {
background-color: red;
}
This selects the spans inside of the row and changes their bg colors.
http://jsfiddle.net/snoapps/2oha40h5/
EDIT:
maioman's response probably would be safer since you might add more elements to the .row that aren't span's, then their backgrounds wouldn't be highlighted. So .row> *:hover {} would work better then.
Answering my own question here. Thanks you guys for validating that code will indeed work. It is in fact a problem with the rest of the web page so I now need to go through and manually tell it to not apply a hover to nearly every other element. Thanks again everyone!

How to prevent the CSS `:before` text being editable while the `div` itself is editable?

I have an editable body with a div:
<body contenteditable="true">
<div class="paragraph">Text</div>
<body/>
And a :before style:
div.paragraph:before {
content: "☑";
}
Fiddle: http://jsfiddle.net/uy9xs5p0/
In Firefox I can put the cursor at the beginning of the text and press backspace and the check mark gets deleted. How to prevent that?
You are setting the contenteditable in the parent div, therefore when erasing, you are deleting the div.paragraph, so the pseudo will be gone.
See that if you set the property in the child div instead, you can make it work.
div.paragraph:before {
content: "☑";
}
<div>
<div contenteditable="true" class="paragraph">Text</div>
</div>
When this issue is reproduced, (via this fiddle, for instance) the developer tools show that div.paragraph is removed. Only a text node remains.
becomes
To stop the div from being removed, don't give its parent contenteditable. Use this instead:
<body>
<div class="paragraph" contenteditable="true">Text</div>
</body>
Fiddle: http://jsfiddle.net/5y00q6ya/3/
You are not editing the :before content.
It just removes the whole .paragraph element once it gets empty, or if you backspace when you are at the beginning of the tag.
The other answers explain the problem. If a div inherits its edit-ability from its parent, it is possible to remove the child div itself and together with the div also the before-content.
In order to prevent this, it is necessary that the editable div must not be placed in an editable parent. This makes it necessary to put every editable div into a non editable parent div to preserve the editable child div.
The following example shows this
div.node {
margin-left: 1em;
}
div.paragraph:before {
content: "☑";
}
<div contenteditable="false" class="node">
<div contenteditable="true" class="paragraph">Major</div>
<div contenteditable="false" class="node">
<div contenteditable="true" class="paragraph">Minor</div>
</div>
</div>
Possible workaround this problem. This seems to working as you want it to be.
<div contenteditable="true" class="upper-div">
<div class="paragraph">Text</div>
</div>
div.upper-div:before {
content: "☑";
display:inline-block;
}
.paragraph{display:inline-block;}

On hover show DIV flicker

I am facing very annoying problem.
I have 2 div's like bellow, first div is product image, and second one is overlay that should be shown when user hovers over product image.
It does work, but when image is hovered, overlay doesnt stop flickering.
I tried few "hacks" by setting opacity and nothing works.
<div class="product-container">
<div class="product-image"><img src="http://placehold.it/200x200">
<div class="overlay">PRICE</div>
</div>
URL is http://jsfiddle.net/MZ3eE/
I know JS could be used, but in this case i need pure CSS solution.
After looking at the new fiddle
you need to do this
.product-container:hover .overlay-box {
display: block;
}
instead of
.product-img-box:hover + .overlay-box {
display: block;
}
http://jsfiddle.net/avxLA/1/
Apply the :hover to the .product-image div instead of the img like so:
.product-image:hover .overlay {
display:block;
}
updated fiddle
For starters, there is an unclosed <div> there, so not quite sure how you want it. Anyway if you want it like this:
<div class="product-container">
<div class="product-image">
<img src="http://placehold.it/200x200">
<div class="overlay">PRICE</div>
</div>
</div>
then like others said :
.product-image:hover .overlay {display:block;}
will do fine. Otherwise if you want it like that(which makes more sense tbh):
<div class="product-container">
<div class="product-image"><img src="http://placehold.it/200x200"></div>
<div class="overlay">PRICE</div>
</div>
you should put it on the containers :hover like that :
.product-container:hover .overlay {display:block;}

Text on Hover an image in Css

Hey guys I'm trying to implement Paper unfoding effect in a webpage of a wesite I'm developing. Im using the pfold jquery plugin, but I want a text to appear on hover and I did it many times but doesnt work. Here is my code:
HTML:
<div class="uc-container">
<div class="uc-initial-content">
<!--<img src="fm.png" alt="FM" /> -->
<img src="fm.png" alt="Fm" title="Fm" id="hoverFm">
<p class="textSponsor">92.7 BIG FM</p>
<span class="icon-eye"></span>
</div>
<div class="uc-final-content">
<img src="fm.png" alt="FM" />
<div class="title"><h4>FM</h4> </div>
<span class="icon-cancel"></span>
</div>
</div>
And This is the CSS For same:
#hoverFm .textSponsor{
position: relative;
margin-right: auto;
margin-left: auto;
visibility: hidden;
}
#hoverFm:hover .textSponsor{
visibility: visible;
}
When Im doing this the text just simply comes below my picture . I'm not getting where I'm going wrong. And when I'm creating a new div which contains only <img> and <p> tag then my image is getting small (I guess its because of the code I wrote for resizing and paper folding effect which is gettin hampered due to this and then also text on hover is not coming)
If you guys wanna see what actually I'm making :
The link to the demo site is: http://tympanus.net/Development/PFold/index3.html
and the code for same is available at link: http://tympanus.net/codrops/2012/10/17/pfold-paper-like-unfolding-effect/comment-page-2/#comment-450779
And the github link for code is: https://github.com/codrops/PFold
I tried it a lot to figure out but was unable so please help someone. It will really be appreciated. Thanks in Advance!!
#hoverFm:hover .textSponsor
This does never really happen, because .textSponsor is not a child of #hoverGM, it is a sibling. You need to use the next selector, which is +:
#hoverFm:hover + .textSponsor
You could also change the structure to
<div class="uc-initial-content" id="hoverFm">
<img src="fm.png" alt="Fm" title="Fm">
<p class="textSponsor">92.7 BIG FM</p>
Then your original selector would work because now it really is a child.

Resources