I have a newsfeed which is obviously organized by an . When the user hovers over each of the items, the background is highlighted. I'd also like to have a small "x" in the top right hand corner of each item, only shown when hovered. This "x" would be a delete button to remove that post.
Right now I just have some basic html stating: <div class="hide-button"><a href="#">x</a></div>
I know that I don't want the "x" displayed in the html, but rather have it in the CSS. So I have the <li>
css below for hovering, as well as the CSS for the hide button. I'd like to know the best method to integrate the hide button div into the <li>
.hide-button {
float: right;
margin-top: -13px;
font-size: 11px;
font-family: helvetica;
color: gray;
}
.hide-button a{
text-decoration: none;
color:gray;
}
.hide-button a:hover {
text-decoration: underline;
color:gray;
}
and the list:
.newsfeedlist li {
background: white;
border-bottom: 1px solid #E4E4E4;
padding: 12px 0px 12px 0px;
overflow: hidden;
}
.newsfeedlist li:hover {
background-color: #F3F3F3;
}
Thank you so much!!!!!
To display the element on hover, make them invisible by default using display: none property. Then add :hover property on that element with display: block to make it visible on hover.
To display div element using CSS on hover a tag: First, set the div element invisible i.e display:none;. By using the adjacent sibling selector and hover on a tag to display the div element.
Set visibility: hidden and opacity: 0 for not displaying image first time. Using transition property for adding animation. When hovering on parent <div> then change the child element visibility: visible and opacity: 0.7; . You can change the position of text container using the top bottom left right CSS properties.
Presuming your delete buttons are inside another container you could do something like
.hide-button {
float: right;
margin-top: -13px;
font-size: 11px;
font-family: helvetica;
color: tray;
display: none;
}
... the other bits of CSS ...
.newsfeedlist li:hover .hide-button {
display: block;
}
Modifying the close button to be hidden by default and then when hovering on a list item you set the display back again on the close button.
Hope this makes sense
Tim
You might really be in need of this: Demo at jsFiddle.net I modified an example and tushed it up for multiple content areas or images.
But hide-button
element in the li
and do
.newsfeedlist li:hover .hide-button {
display: inline-block;
}
and add display: none;
to .hide-button
Otherwise, there's always javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With