I have a div with id that needed to be access with css and change width and height. But its located inside of another div. How to add styles to that inner css. Please look at the code below

<div> <div> <div> <div></div> </div> </div> </div> 

I need to add styles to the #map

7

4 Answers

css if map is only in this place;

.panel #collapseThree #map { width: 200px height: 200px; } 

Id - a unique identifier element. On one page, one identifier is used only once, although you can use several identical identifiers within a single page, but it can cause problems when using HTML-anchors and JS. If you try to assign a single element (HTML-tag), two different ID, then the rules will only work from the first ID When using a class, one HTML-descriptor can assign styles from multiple classes simultaneously. Necessary and use classes and ids, depending on the intended purpose. In most cases it is better to use the class, so do not accidentally use the id on the same page more than once. But where necessary, should be used id: selection of unique block page for anchors for JS, etc.

Here: 

I would recommend learning more about CSS selectors, and using "Inspect Element" option of your browser.

1

The answers already given should apply styles to your div with id map. But it might not mean that those styles will be the ones actually being applied.

You will have to look with a debugger (firebug, firefox internal inspector, safari inspector etc) and see which styles eventually "win" on the element. Other css styles which are applied with "!important" will take precedence on your map div, therefore "ignoring" the styles you applied. In this case you could try adding your styles with an "!important" too. If posible also try and add a class, instead of just using an ID. Classes also take precedence over IDs.

I also suspect you are using some library that builds the map inside of you div. This library might also add it's own styling to the element itself by adding the "style" attribute with some css. For example the resulting div might look like

<div></div> 

Which will also take precedence over css applied by stylesheet

Here is an explanation of the order of css cacades - if you need

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy