tags:

views:

795

answers:

2

Hi guys,

I need to remove the border of one block from the rest of the right sidebar blocks but I don't know how to do that. I already tried to do it like this:

#sidebar-right div#block-block-14 {
    border:1px dashed orange !important;
    text-align:center;
}

div#block-block-14 is the drupal generated id of the block:

<div id="block-block-14">

But I can't remove its border.

Thanks in advance :)

A: 

As it's an id that you are trying to target, you should have the # character before it:

#div#block-block-14 {
   border:1px dashed orange !important;
   text-align:center;
}

As the id is unique for the page, you only have to specify one id, you don't need to specify the #sidebar-right id also.

I'm not sure how it feels about the # character inside the id, though. It might be impossible to target an id that looks that way. In that case you have to change how the id is generated, or find another way of targetting the element, like adding a class name to the element.

Edit:
With the correction, the id looks fine, and you only have to use:

#block-block-14 {
   border:1px dashed orange !important;
   text-align:center;
}
Guffa
Sorry for this -> <div id="div#block-block-14">. What i meant was <div id="block-block-14"> that is generated by drupal. I will edit it now. Thanks :)
marknt15
A: 

The hash inside the id will ruin it for you. Drupal wont place a hash inside the div be default, so you probably need to look to your theme. block.tpl.php is probably the template that is creating this problem for you. Normally the div# would not be included in the id, the rest of it tells you which block it is, block-block-14 simply means the block from the block module with id 14. Different modules may have slightly different naming schemes but the idea is generally the same.

Once you get Drupal to stop printing the extra div# you should be able to do this in your css:

#block-block-14 {
    ....
}

Unless you use panels you usually don't need anything other than the id, since each block can only be located in one region. Depending on how the rule you want to overwrite was enforced, you might need to add some extra selectors to give it more importance.

googletorp
Thanks sir, I have already did it in my localhost but can't seem to change it in the production server. I have tried to truncate the cache tables, clear the browser cache and clear the views from the administer page but it is still there. Any suggestions? Thanks
marknt15
If you have cleared the cache, and have uploaded the changes to your production server things should work just fine. Try to check the markup you get to see if that's the problem, if the markup is fine, your problem is the CSS.
googletorp

related questions