I want to assign a div 2 display properties, I'm not sure what the correct syntax is...
#div2 {
display:none;inline-block;
}
What is the correct way to do this?
UPDATE:
#div2 {
display:none;
}
$(function() {
$("#div1").mouseover(function() {
$("#div2").css('display', 'inline-block');
}).mouseout(function(){
$("#div2").css('display', 'none');
});
});
Answer: Use the jQuery css() Method You can use the jQuery css() method to change the CSS display property value to none or block or any other value. The css() method apply style rules directly to the elements i.e. inline.
With display: block , elements are stacked one after each other, vertically, and every element takes up 100% of the page. The values assigned to the width and height properties are respected, if you set them, along with margin and padding .
Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.
The display property specifies the display behavior (the type of rendering box) of an element. In HTML, the default display property value is taken from the HTML specifications or from the browser/user default style sheet. The default value in XML is inline, including SVG elements.
You can only set one value at a time to the display
property. In this case, the display: none
will cause the div to not be rendered at all, so the inline-block
would be totally irrelevant here.
I assume you want to somehow toggle the visibility using javascript. This requires you to toggle the display property between none
and inline-block
. As I said, you can always just have one value here.
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