How to have no border around a DIV


Tags: html,css,css3

Problem :

I have the following DIV in my page:

<div id="leftNavCustom" class="leftMenu">             
    <div class="menu-item">
        <h4><a href="#">Menu</a></h4>
        <ul>
            <li id="u"><a >Why Choose Us</a></li>
            <li id="u"><a >Physicians</a></li>
            <li id="u"><a >Medical Specialties</a></li>
            <li id="u"><a >Locations</a></li>
            <li id="u"><a >Urgent Care</a></li>
            <li id="u"><a >Radiology</a></li>
            <li id="u"><a >Lab</a></li>
        </ul>
    </div>
</div>

which creates a hover over menu expander.

My CSS is as follows:

#leftNavCustom {
    display: block;
    z-index: 5;
    font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
    line-height: 1.5;
    margin: 0;
    width: 240px;
    -webkit-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    -moz-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    padding: 0;
    background: #00ff00;
}
.leftMenu {
    position: fixed;
    left: 22px;
    top: 65px;
    margin: 0;
    padding: 0;
}
.menu-item, .menu-item2 {
    background: url('../theImages/bg_80_b.png');
    width: 240px;
    font-family: 'nexa_boldregular';
    font-size: 19px;
    margin: 0;
    padding: 0;
    text-align: left;
}

/*Menu Header Styles*/
.menu-item h4 {
    border-bottom: 1px solid rgba(0,0,0,0.3);
    border-top: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    padding: 7px 12px;

    /*Gradient*/
    background: #e73827; /* Old browsers */
    background: -moz-linear-gradient(top, #e73827 0%, #f02f17 29%, #f6290c 47%, #f27c32 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e73827), color-stop(29%,#f02f17), color-stop(47%,#f6290c), color-stop(100%,#f27c32)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 47%,#f27c32 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 47%,#f27c32 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 47%,#f27c32 100%); /* IE10+ */
    background: linear-gradient(to bottom, #e73827 0%,#f02f17 29%,#f6290c 47%,#f27c32 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e73827', endColorstr='#f27c32',GradientType=0 ); /* IE6-9 */
}

/*Menu Header Styles*/
.menu-item2 h4 {
    border-bottom: 1px solid rgba(0,0,0,0.3);
    border-top: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    padding: 7px 12px;

    /*Gradient*/
    background: #036ca9; /* Old browsers */
    background: -moz-linear-gradient(top,  #036ca9 0%, #025c90 44%, #00466e 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#036ca9), color-stop(44%,#025c90), color-stop(100%,#00466e)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #036ca9 0%,#025c90 44%,#00466e 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #036ca9 0%,#025c90 44%,#00466e 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #036ca9 0%,#025c90 44%,#00466e 100%); /* IE10+ */
    background: linear-gradient(to bottom,  #036ca9 0%,#025c90 44%,#00466e 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#036ca9', endColorstr='#00466e',GradientType=0 ); /* IE6-9 */
}

.menu-item h4:hover {  
    background: #f27c32; /* Old browsers */
    background: -moz-linear-gradient(top, #f27c32 0%, #f6290c 53%, #f02f17 71%, #e73827 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f27c32), color-stop(53%,#f6290c), color-stop(71%,#f02f17), color-stop(100%,#e73827)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #f27c32 0%,#f6290c 53%,#f02f17 71%,#e73827 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #f27c32 0%,#f6290c 53%,#f02f17 71%,#e73827 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #f27c32 0%,#f6290c 53%,#f02f17 71%,#e73827 100%); /* IE10+ */
    background: linear-gradient(to bottom, #f27c32 0%,#f6290c 53%,#f02f17 71%,#e73827 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f27c32', endColorstr='#e73827',GradientType=0 ); /* IE6-9 */
}

.menu-item2 h4:hover {  
    background: #00a3cc; /* Old browsers */
    background: -moz-linear-gradient(top,  #00a3cc 0%, #005a6e 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00a3cc), color-stop(100%,#005a6e)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #00a3cc 0%,#005a6e 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #00a3cc 0%,#005a6e 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #00a3cc 0%,#005a6e 100%); /* IE10+ */
    background: linear-gradient(to bottom,  #00a3cc 0%,#005a6e 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00a3cc', endColorstr='#005a6e',GradientType=0 ); /* IE6-9 */

}

.menu-item h4 a, .menu-item2 h4 a {
    color: white;
    display: block;
    text-decoration: none;
    width: 240px;
}

/*ul Styles*/
.menu-item ul {
    background: url('theImages/bg_80_b.png');
    font-size: 13px;
    line-height: 30px;
    height: 0px;
    list-style-type: none;
    overflow: hidden;
    padding: 0px;

    *Animation*/
    -webkit-transition: height 1s ease;
    -moz-transition: height 1s ease;
    -o-transition: height 1s ease;
    -ms-transition: height 1s ease;
    transition: height 1s ease;
}

.menu-item:hover ul {
    width: 240px;
    height: 300px;
    -webkit-border-radius: 0 0 5px 5px;
    -moz-border-radius: 0 0 5px 5px;
    border-radius: 0 0 5px 5px;
}

.menu-item ul li#u a {
    color: #fff;
    cursor: pointer;
    display: block;
    height: 25px;
    line-height: 25px;
    text-indent: 0px;
    text-decoration: none;
    width: 100%;
    font-family: 'nexa_boldregular';
    font-size: 19px;
}

/*li Styles*/
.menu-item li#u {
    border-bottom: 1px #13476F solid;
    padding: 8px;
}

.menu-item li#u:hover {
    background: #5196AB;
}
.menu-item li#firstOne {
    display: absolute;
    top: 0;
    left: 0;
    background-color: #FFFFFF;
    text-align: center;
    height: 75px;
    line-height: 75px;
    border-bottom: 1px solid #FF7263;
    vertical-align: middle;
}
.menu-item li#firstOne img {
    vertical-align: middle;
}

By default it creates a big space around the menu as shown below:

enter image description here

The only way the menu comes out normal like I would like:

enter image description here

Is to add the following style to the above css file:

* {
     margin: 0;
     padding: 0;
}

But that makes some of my other DIVS on the page out of place. I tried adding margin and padding to every single code in my CSS but nothing works without adding the few lines shown above.

How do i modify my existing css code to fix it?

JSFIDDLE: http://jsfiddle.net/s2z6f/



Solution :

Remove the margin from the specific elements that shouldn't have it (the h4 and the ul of .menu-item). You can do this rather than using * as the selector.

.menu-item h4, .menu-item ul {
    margin: 0;
}

http://jsfiddle.net/v9xp2/


    CSS Howto..

    How to style a credit card expiration date input field to include spaces and forward slash?

    Angular Material Flexbox - How to add margin between wrapped rows?

    How to exclude css files from auto formatting in IntelliJ

    How to reduce the wiDth of dropdown-menu?

    How do I remove the underline from an image wrapped in an anchor?

    How to make the first column of a table invisible?

    How will I change CSS based on classes and id using jQuery

    How do I add a mouseover drop shadow effect for circular images?

    How to design resolution independent CSS elements?

    How can I slide the sidebar out of view and make the content flexbox resize to fill the void?

    css how to make an elements margin-bottom go to bottom of its container

    How to change css content hover effect background color css php in this situation?

    how to arrange divs with css as a grid?

    How can I transform dots to line between CSS menu items?

    CSS: how to calculate margin inside a div for a fluid layout

    How do I prevent fadeIn/Out blinking with expanding/collapsing header?

    How can i overwrite media queries defined in Bootstrap CSS

    How do I center a div along the y axis?

    How to create this material design background (see image below) with CSS?

    How can I select the item that doesn't have attribute [duplicate]

    Pure CSS3 show/hide full height div with transition

    How to make overflow blocks working well ()

    How to do grid of div elements?

    How to get tr:nth-child which has css applied

    How to preload css :hover background images

    How to run a CSS animation infintely forwards

    How to enable -webkit-animation/transition-property for :before and :after pseudo elements?

    How to use one single png image to create multiple website buttons (and their hovers)

    hide/show element with add/removeClass with CSS transition

    How do I add extra slides to this pure CSS text rotator?