I am using Bootstrap for my css themes. The themes are compiled and saved into the database for use later on. This means that the pages only have access to the compiled css and not the less files.
Given that, how can I apply Bootstrap’s tr:hover
effect to various divs? I need the color to be the same as what is defined for tr:hover
and I can’t use less variables.
Bootstrap's style:
.table tbody tr:hover td,
.table tbody tr:hover th {
background-color: #f5f5f5;
}
Is it possible to define a css element based on another one that is assigned to a tr
? Is there a way to grab the style using jQuery?
Any suggestions?
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.
You might have linked your stylesheet to your HTML file improperly. Some other CSS in the context of your project may be overriding the piece that you've given here. You might be running into browser compatibility issues with the :hover selector or something else in your code that is breaking the styling.
The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.
Have a class for the div
as .hoverDiv
and the CSS for this:
.hoverDiv {background: #fff;}
.hoverDiv:hover {background: #f5f5f5;}
$(document).ready(function(){
$(".hoverDiv").hover(function(){
$(this).css("background", "#f5f5f5");
}, function(){
$(this).css("background", "#fff");
});
});
$(".table tbody tr:hover").css("background-color")
:$(document).ready(function(){
$(".hoverDiv").hover(function(){
$(this).css("background", $(".table tbody tr:hover").css("background-color"));
}, function(){
$(this).css("background", $(".table tbody tr").css("background-color"));
});
});
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