Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Location
    Darlington UK
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    CSS drop down sub menu text needs to be wider than parent

    Hi, I have created a drop down menu using lists. The text in the drop down menu needs to cover a wider distance than what its parent <li> is set to. If I make the sub menu <li> wider the text will still only go to the width of the main menu parent <li> and then wrap to the next line, this is really bugging me. Can anyone help me work around this issue.

    Here is my CSS code

    Code:
    #menu {
    	font-size: 14px;
    	text-align: center;
    }
    #menu ul {
    	padding:0;
    	margin:0;
    }
    #menu li {
    	position: relative;
    	float: left;
    	list-style: none;
    	margin: 0;
    	padding:0;
    	font-family: "Arial Black", Gadget, sans-serif;
    }
    #menu li a {
    	width:120px;
    	height: 35px;
    	display: block;
    	text-decoration:none;
    	line-height: 35px;
    	color: white;
    	font-family: Arial, Helvetica, sans-serif;
    }
    #menu li a:hover {
    	font-family: Arial, Helvetica, sans-serif;
    	color: #A2CAA3;
    }
    #menu ul ul {
    	position: absolute;
    	top: 35px;
    	left:25px;
    	background-color: #0A4133;
    	visibility: hidden;
    }
    #menu ul li:hover ul {
            width: 150px;
    	padding-left: 5px;
    	visibility:visible;
    	z-index: 900;
    	color: #A2CAA3;
    	font-size: 10px;
    	text-align: left;
    }

  • #2
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Have you tried setting negative value margins?

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Location
    Darlington UK
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thanks for the reply, i managed to solve it after reading this link:
    http://stackoverflow.com/questions/7...-its-parent-li


    I just had to add "white-space:nowrap;" to the <a> elements


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •