Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign div 2 display properties?

Tags:

html

css

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');
  });
});
like image 990
thedeepfield Avatar asked Feb 12 '11 21:02

thedeepfield


People also ask

How do I change my display property?

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.

Is the value assign with display property?

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 .

How do I display two div tags side by side?

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.

What are the display properties?

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.


1 Answers

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.

like image 100
Holger Just Avatar answered Nov 01 '22 22:11

Holger Just