How do I make the sub-navigation links in the default Twenty Twelve Wordpress theme display over the wrapper/container?
header.php:
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav>
style.css:
.site-content nav {
clear: both;
overflow: hidden;
}
.main-navigation .assistive-text:hover,
.main-navigation .assistive-text:active,
.main-navigation .assistive-text:focus {
background: #fff;
border: 2px solid #333;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
clip: auto !important;
color: #000;
display: block;
font-size: 12px;
padding: 12px;
position: absolute;
top: 5px;
left: 5px;
z-index: 100000; /* Above WP toolbar */
}
.main-navigation {
text-align: center;
clear: both;
}
.main-navigation li {
font-size: 12px;
font-size: 0.8571428571rem;
}
.main-navigation a {color: #5e5e5e;}
.main-navigation a:hover {color: #21759b;}
.main-navigation ul.nav-menu,
.main-navigation div.nav-menu > ul {display: none;}
.main-navigation ul.nav-menu.toggled-on,
.menu-toggle {display: inline-block;}
.menu-toggle {
margin: 16px 0;
margin: 1.1428571429rem 0;
}
.main-navigation ul.nav-menu.toggled-on li {margin-bottom: 16px;}
#media screen and (min-width: 600px) {
.main-navigation ul.nav-menu,
.main-navigation div.nav-menu > ul {
display: inline-block !important;
text-align: center;
width: 100%;
}
.main-navigation ul {text-indent: 0;}
.main-navigation li a,
.main-navigation li {
display: inline-block;
text-decoration: none;
margin: 0 16px;
margin: 0 1.1428571429rem;
}
.main-navigation li a {
border-bottom: 0;
color: #6a6a6a;
padding: 12px 0;
text-transform: uppercase;
white-space: nowrap;
}
.main-navigation li a:hover {color: #89CBBF;}
.main-navigation li {
position: relative;
margin: 0;
}
.main-navigation li:hover {background: #ededed;}
.main-navigation li ul {
display: none;
margin: 0;
padding: 0;
position: absolute;
top: 100%;
z-index: 1;
}
.main-navigation li ul ul {
top: 0;
left: 100%;
}
.main-navigation ul li:hover > ul {
border-left: 0;
display: block;
}
.main-navigation li ul li a {
background: #efefef;
border-bottom: 1px solid #ededed;
display: block;
font-size: 11px;
font-size: 0.7857142857rem;
min-width: 180px;
min-width: 12.857142857rem;
white-space: normal;
margin: 0;
padding: 12px 5px;
-moz-hyphens: auto;
-o-hyphens: auto;
-ms-word-break: break-all;
-webkit-hyphens: auto;
hyphens: auto;
word-break: break-all;
word-wrap: break-word;
}
.main-navigation li ul li a:hover {
background: #e3e3e3;
color: #89CBBF;
}
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a,
.main-navigation .current_page_item > a,
.main-navigation .current_page_ancestor > a {
color: #89CBBF;
font-weight: bold;
}
.menu-toggle {display: none;}
I think you shloud try removing the overflow: hidden from .site
Related
I am trying to make the site title of my header clickable and link back to the home page. (For example, google.com - if you click the google logo you go back to the google homepage.) I have added all of the correct code to my header.php but it still won't allow me to click the site title. Does anyone see any errors or have any solutions? Thanks in advance.
my header.php
<?php
/**
*
*
*
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="ht-page">
<header id="ht-masthead" class="ht-site-header">
<div class="ht-container ht-clearfix">
<div id="ht-site-branding">
<?php
if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) :
the_custom_logo();
else :
if ( is_front_page() ) : ?>
<h1 class="ht-site-title"><?php bloginfo( 'name' ); ?></h1>
<?php else : ?>
<p class="ht-site-title"><?php bloginfo( 'name' ); ?></p>
<?php endif; ?>
<p class="ht-site-description"><?php bloginfo( 'description' ); ?></p>
<?php endif; ?>
</div><!-- .site-branding -->
<nav id="ht-site-navigation" class="ht-main-navigation">
<div class="toggle-bar"><span></span></div>
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'container_class' => 'ht-menu ht-clearfix' ,
'menu_class' => 'ht-clearfix',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
) );
?>
</nav><!-- #ht-site-navigation -->
</div>
</header><!-- #ht-masthead -->
<div id="ht-content" class="ht-site-content ht-clearfix">
my css
/*--------------------------------------------------------------
## Header
--------------------------------------------------------------*/
#ht-masthead{
background: #FFF;
height: 70px;
border-bottom: 1px solid #eee;
z-index: 99;
transition: height 0.3s ease;
-moz-transition: height 0.3s ease;
-webkit-transition: height 0.3s ease;
position: fixed;
text-align: center;
width: 0 auto;
margin-right: 38px;
width: 100%;
}
.ht-site-title{
font-family: 'futura_tbold';
font-size: 24px;
text-transform: uppercase;
letter-spacing: 6px;
line-height: 1;
margin-bottom: 8px;
margin-top:5px;
margin-left: 75px;
text-align: left;
float: left;
padding: 15px 0;
transition: padding 0.3s ease;
-moz-transition: padding 0.3s ease;
-webkit-transition: padding 0.3s ease;
}
.ht-site-title a{
text-decoration: none;
color: #000;
}
.ht-site-description{
color: #EEE;
margin: 0;
font-size: 15px;
font-style: italic;
line-height: 1;
}
.ht-site-description a{
color: #333;
}
/*--------------------------------------------------------------
## General
--------------------------------------------------------------*/
#ht-content {
padding-top: 200px;
}
.ht-section {
padding: 60px 0;
background: #FFF;
}
.ht-section-title-tagline {
margin-bottom: 60px;
text-align: center;
}
.ht-section-title {
font-weight: 400;
letter-spacing: 1px;
text-transform: uppercase;
font-size: 36px;
width: 60%;
margin: 0 auto 15px;
}
.ht-section-title:last-child {
margin-bottom: 0;
}
.ht-section-tagline {
font-size: 20px;
width: 70%;
margin: 0 auto;
}
#ht-page {
width: 100% !important;
margin: 0 auto;
max-width: 100% !important;
overflow: hidden !important;
}
/*--------------------------------------------------------------
## Menus
--------------------------------------------------------------*/
#ht-site-navigation {
position: absolute;
width: 100%;
padding: 15px 0;
transition: padding 0.3s ease;
-moz-transition: padding 0.3s ease;
-webkit-transition: padding 0.3s ease;
float: right;
}
.ht-sticky #ht-site-navigation {
padding: 17px 0;
}
.ht-main-navigation .ht-menu {}
.ht-main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
display: inline-block;
position: relative;
}
.ht-main-navigation li {
float: left;
margin-left: 30px;
}
.ht-main-navigation a {
display: block;
text-decoration: none;
color: #000;
text-transform: uppercase;
font-size: 15px;
font-family: 'Raleway', sans-serif;
line-height: 36px;
padding: 0 15px;
font-weight: 600;
letter-spacing: 2px;
padding-bottom: 40px;
}
.ht-main-navigation ul ul {
position: absolute;
left: 0;
top: 100%;
background: #FFF;
min-width: 200px;
right:0;
z-index: 999;
padding: 8px;
margin-top: -21px;
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.05);
height:300px;
transform: scaleY(0);
-webkit-transform-origin: top;
-moz-transform-origin: top;
transform-origin: top;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
opacity: 0;
}
.ht-sticky .ht-main-navigation ul ul {
margin-top: 17px;
}
.ht-main-navigation ul ul ul {
left: 100%;
top: 0;
margin: 0 0 0 8px;
border-top: 0;
}
.ht-sticky .ht-main-navigation ul ul ul {
margin-top: 0;
}
.ht-main-navigation ul ul a {
text-transform: uppercase;
font-weight: 400;
color: #444;
line-height: 1.5;
padding: 7px 25px;
font-size: 12px;
text-align: left;
}
.ht-main-navigation ul ul li:first-child {
padding-top: 15px;
}
.ht-main-navigation ul ul li {
float: none;
margin: 0 0 5px;
}
.ht-main-navigation ul ul li:last-child {
margin-bottom: 0;
}
.ht-main-navigation ul li:hover > ul {
opacity: 1;
transform: scaleY(1);
}
.page-template-home-template .ht-main-navigation .current_page_item > a,
.page-template-home-template .ht-main-navigation .current-menu-item > a,
.page-template-home-template .ht-main-navigation .current_page_ancestor > a,
.home.blog .ht-main-navigation .current_page_item > a,
.home.blog .ht-main-navigation .current-menu-item > a,
.home.blog .ht-main-navigation .current_page_ancestor > a {
background: none;
color: inherit;
}
.ht-main-navigation li:hover > a,
.page-template-home-template .ht-main-navigation li:hover > a,
.home.blog .ht-main-navigation li:hover > a,
.ht-main-navigation .current_page_item > a,
.ht-main-navigation .current-menu-item > a,
.ht-main-navigation .current_page_ancestor > a,
.page-template-home-template .ht-main-navigation .current > a,
.home.blog .ht-main-navigation .current > a {
color: #000;
text-decoration: none;
}
.site-main .comment-navigation,
.site-main .posts-navigation,
.site-main .post-navigation {
margin: 0 0 15px;
overflow: hidden;
}
.comment-navigation .nav-previous,
.posts-navigation .nav-previous,
.post-navigation .nav-previous {
float: left;
width: 50%;
}
.comment-navigation .nav-next,
.posts-navigation .nav-next,
.post-navigation .nav-next {
float: right;
text-align: right;
width: 50%;
}
I'm not sure if you mean clicking the title of the tab or making the header tag clickable.
If you mean making the header tag clickable, then try the following snippet:
header {
background-color: red;
height: 50px;
width: 100%;
cursor: pointer;
}
<header onclick="alert('Clicked')"></header>
If you want to make the title of tab clickable, you're out of luck.
It's impossible.
If you want a text link, use a href, if you want an image link, put img tag in a tag
* {
padding-bottom: 10px;
}
Google!
<a href="https://google.com">
<img src="https://www.google.co.uk/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png">
</a>
Note: Links wont work in here because of the snippet thingy
I am trying to get the header of my site and the navigation on the same line. I want the header to be aligned left and the navigation to be centered. My code doesn't seem to be working, so I was wondering if anyone has any solutions? Thanks in advance.
an example of what I am trying to have it look like...
my header.php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width">
<title><?php bloginfo('name'); ?></title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div class="container">
<!-- site-header -->
<header class="site-header">
<h1><?php bloginfo('name'); ?></h1>
<h5><?php bloginfo('description'); ?></h5>
<nav class="site-nav">
<?php
wp_nav_menu(array(
'menu' => 'Primary Menu Links',
'container_id' => 'cssmenu',
'walker' => new CSS_Menu_Walker()
));
?>
</nav>
</header>
</div>
my css
.site-header h1 {
margin: 0;
font-family: 'futura_tbold';
font-size: 24px;
text-align: left;
text-transform: uppercase;
letter-spacing: 6px;
padding-top: 20px;
position: fixed;
z-index: 10000;
}
/* Drop Down Menu */
#cssmenu,
#cssmenu ul,
#cssmenu li,
#cssmenu a {
}
#cssmenu {
height: 37px;
text-align: center;
margin-bottom:50px;
width: 0 auto;
margin-right:38px;
}
#cssmenu,
#cssmenu > ul > li > ul > li a:hover
}
#cssmenu > ul {
}
#cssmenu > ul > li {
list-style: inside none;
position: relative;
display: inline-block;
}
#cssmenu > ul > li > a {
display: block;
position: relative;
padding: 12px 20px;
text-align: center;
text-decoration: none;
font-size: 13px;
font-family: 'textaw00-heavyregular', 'AvenirNextLTW01', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif';
color: #2f3847;
text-transform:uppercase;
letter-spacing: 1px;
font-weight:normal;
-webkit-font-smoothing: antialiased;
}
#cssmenu > ul > li > a:hover {
color:#8F1E3E;
}
#cssmenu > ul > li:first-child > a {
}
#cssmenu > ul > li > a:after {
content: '';
position: absolute;
}
#cssmenu ul li.has-sub:hover > a:after {
position: absolute;
top: 28px;
left: 11px;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #3d0d1d;
border-left: 7px solid transparent;
border-bottom-color: rgba(61, 13, 29, 1);
content: '';
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #3d0d1d transparent;
}
#cssmenu > ul > li.has-sub > a:before {
}
#cssmenu > ul > li.has-sub:hover > a:before {
}
#cssmenu ul li.has-sub:hover > a {
}
#cssmenu ul li.has-sub:hover > ul,
#cssmenu ul li.has-sub:hover > div {
display: block;
}
#cssmenu ul li.has-sub > a:hover {
color: #8F1E3E;
}
#cssmenu ul li > ul,
#cssmenu ul li > div {
display: none;
width: auto;
position: absolute;
top: 38px;
padding: 10px 0;
background: #490f20;
border-radius: 0px 0px 0px 0px;
z-index: 999;
}
#cssmenu ul li > ul {
width: 200px;
}
#cssmenu ul li > ul li {
display: block;
list-style: inside none;
padding: 0;
margin: 0;
position: relative;
}
#cssmenu ul li > ul li a {
outline: none;
display: block;
position: relative;
margin: 0;
padding: 8px 20px;
color: #ffffff;
text-decoration: none;
text-align: left;
font-size: 13px;
font-family: 'textaw00-heavyregular', 'AvenirNextLTW01', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif';
text-transform:uppercase;
letter-spacing: 1px;
font-weight:normal;
-webkit-font-smoothing: antialiased;
line-height:25px;
}
#cssmenu ul ul a:hover {
color: #ffffff;
background-color:#8F1E3E;
}
#cssmenu > ul > li.has-sub > a:hover:before {
border-top: 5px solid #ffffff;
}
Here you go buddy hope this helps
Jsfiddle
<div class="navigation">
<div class="container">
<div class="logo">
<!-- <img src="#" alt=""> -->
<span>LOGO</span>
</div>
<nav>
<ul>
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
<li>Page 4</li>
</ul>
</nav>
</div>
</div>
.navigation {
float: left;
width: 100%;
padding: 10px 0;
border-bottom: 2px solid black;
}
.container {
max-width: 90%;
margin: 0 auto;
position: relative;
}
.logo {
position: absolute;
top: 0;
left: 0;
}
nav ul {
margin: 0 auto;
text-align: center;
}
nav ul li {
display: inline-block;
}
I added second nav menu (nav2), however it adopts the look of first (nav1) menu and I cannot fix it. On the other hand its content is different.
piece of header.php:
<nav class="nav" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'extra_menu&container_class=menu&fallback_cb=false&show_home=1' ) ); ?>
</nav><!-- .nav -->
<nav2 class="nav" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'top_menu', 'menu' => 'nav2')); ?>
<form role="search" method="get" class="header-form" action="<?php echo esc_url( home_url() ); ?>">
<fieldset>
<input type="text" name="s" class="header-text uniform" size="15" title="<?php esc_attr_e( 'Search','adelle-theme' ); ?>" />
<input type="submit" class="uniform" value="<?php esc_attr_e( 'Search','adelle-theme' ); ?>" />
</fieldset>
</form>
</nav2><!-- .nav2 -->
css:
/* .nav */
.mobile-nav {display: none;}
.tinynav {display: none;}
.nav {position: relative; top: 0px; width: 970px; display: inline-block; background: #000; padding: 0 25px; margin-top: 0px; clear: both; line-height: 1em; text-transform: uppercase;}
.nav:before,
.nav:after {border: 1.6em solid #000; content: ""; display: block; position: absolute; bottom: 0; top: 0; z-index: 1;}
.nav:before {border-left-color: #fff; border-right-width: 1.4em; left: 0;}
.nav:after {border-left-width: 1.4em; border-right-color:#fff; right: 0;}
.nav ul {list-style: none; max-width: 780px; display: inline-block;}
.nav a {display: block; padding: 14px; color: #fff;}
.nav a:hover {text-decoration: underline; color: #fff;}
.nav ul ul a {display: block; padding: 14px; position: relative;}
/* .nav2 */
.mobile-nav {display: none;}
.tinynav {display: none;}
.nav2 {position: fixed; top: 10px; width: 2000px; display: inline-block; background: #fff; padding: 0 25px; margin-top: 40px; clear: both; line-height: 1em; text-transform: uppercase;}
.nav2:before,
.nav2:after {border: 1.6em solid #000; content: ""; display: block; position: absolute; bottom: 0; top: 0; z-index: 1;}
.nav2:before {border-left-color: #fff; border-right-width: 1.4em; left: 0;}
.nav2:after {border-left-width: 1.4em; border-right-color:#fff; right: 0;}
.nav2 ul {list-style: none; max-width: 780px; display: inline-block;}
.nav2 a {display: block; padding: 14px; color: #fff;}
.nav2 a:hover {text-decoration: underline; color: #fff;}
.nav2 ul ul a {display: block; padding: 14px; position: relative;}
If you want 2 navs, one looking different that the other, I'd suggest you use the nav tag for both, but add a unique ID for the second nav and use that ID in your css to overwrite the styles you need to change for the second nav:
<nav>stuff here</nav>
<nav id="secondary-nav">stuff here</nav>
You don't necessarily need the class on the main nav. You can style as such:
nav {
position: relative;
top: 0px;
width: 970px;
}
nav#secondary-nav {
top: 10px;
width: 2000px;
}
Anyone can help me figure out how to stretch out my menu like this http://heatfreehair.com/
Here's how mine is looking right now http://dev1.envisionwebdesign.co/
Below is the php code for the wordpress based site.
<header id="header" class="col-full">
<nav id="navigation" class="col-full" role="navigation">
<?php
if ( function_exists( 'has_nav_menu' ) && has_nav_menu( 'primary-menu' ) ) {
wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'main-nav', 'menu_class' => 'nav fr', 'theme_location' => 'primary-menu' ) );
} else {
?>
<ul id="main-nav" class="nav fl">
<?php if ( is_page() ) $highlight = 'page_item'; else $highlight = 'page_item current_page_item'; ?>
<li class="<?php echo $highlight; ?>"><?php _e( 'Home', 'woothemes' ); ?></li>
<?php wp_list_pages( 'sort_column=menu_order&depth=6&title_li=&exclude=' ); ?>
</ul><!-- /#nav -->
<?php } ?>
</nav><!-- /#navigation -->
</header><!-- /#header -->
Below is the css
#navigation {
float: left;
clear: both;
margin-bottom: 0;
display: none;
}
#header #navigation {
display: block !important;
margin-top: 150px;
}
#header #navigation ul.nav {
float: left;
}
#header #navigation ul.nav > li a {
background: #000000;
float: left;
height: 30px;
line-height: 30px;
display: block;
font-family: "Agency", Verdana;
font-size: 21px;
font-weight: normal;
color: #ffffff;
height: 30px;
padding: 0 44px;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
text-transform: uppercase;
}
#header #navigation ul.nav > li a:hover {
border-color: #e8e3e5;
background: #000000;
color: #f91483;
}
#header #navigation ul.nav > li:hover a {
background: #fff;
}
#header #navigation ul.nav > li.current-menu-item > a,
#header #navigation ul.nav > li.current_page_item > a {
color: #f91483;
}
#header #navigation ul.nav > li.parent a {
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
#header #navigation ul.nav > li.parent a:after {
font-family: 'Agency';
display: inline-block;
font-size: .857em;
margin-left: .618em;
content: ";";
color: #ffffff;
font-weight: normal;
}
#header #navigation ul.nav > li.parent a:hover:before {
content: "";
display: block;
height: 2px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
background: #fff;
z-index: 99999;
}
#header #navigation ul.nav > li.parent:hover a:before {
content: "";
display: block;
height: 2px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
background: #fff;
z-index: 99999;
}
#header #navigation ul.nav > li.parent:hover a:after {
color: #ff007b;
}
#header #navigation ul.nav > li.parent ul li a:after {
visibility: hidden;
}
#header #navigation ul.nav > li.parent ul li.parent a:after {
visibility: visible;
content: "]";
float: right;
}
#header #navigation ul.nav > li.parent ul li.parent ul li a:after {
visibility: hidden;
}
#header #navigation ul.nav > li.parent ul li.parent ul li.parent a:after {
visibility: visible;
content: "]";
}
#header #navigation ul.nav > li.parent ul li.parent ul li.parent ul li a:after {
visibility: hidden;
}
#header #navigation ul.nav ul {
border: none;
margin-top: -1px;
padding: .372em 0;
box-shadow: 0 0.202em 0 0 rgba(232, 227, 229, 0.4);
-webkit-box-shadow: 0 0.202em 0 0 rgba(232, 227, 229, 0.4);
background: #fff;
}
#header #navigation ul.nav ul ul {
left: 100%;
top: -0.372em;
}
h3.nav-toggle {
display: none;
}
This should get you on your way. Trick is to have your nav inside a dive that stretches. Make the nav relative with a set width and then set margin as shown.
the parent div with class fullstretch is automatically width=100% towards the parent conbtainer.
<div class="fullstretch">
<nav></nav>
</div>
body {
margin:0;
}
.fullstretch {
position: relative;
background: #000;
padding: 5px 0;
}
.fullstretch nav {
width: 800px;
position: relative;
margin: 0 auto;
background: #fff;
}
There are 2 ways
pure css
Add this
width: 100%
to your navigation css selector. But if you load your window with not occupying the
whole screen, and then maximize it. you will notice that it doesn't keep intact with the maximum width. Unless if you reload the page again with the maximum window size of course.
However
with javascript
Get the window width
Set the navigation to be the same width as window width (make this
as a function. say function A)
Add event handler to window so that when size window change --> run function A
Hope this gives you an idea for your planning.
I have a link like this
<li><a class='myclass' href="<?php echo base_url();?>index.php/controller">Search</a></li>
and my jquery is
$("a.myclass").click(function(){
var link = $(this);
var url = link.attr("href");
$(".content").load(url);
return false;
});
actually it links correctly the problem is my list in my menu looks ugly not it looks it should be though other li looks ok. when i change to
<li><a class='.myclass.' href="<?php echo base_url();?>index.php/controller">Search</a></li>
it looks correctly but its not linking to anything.
What is the problem here?
Here is my css
.webwidget_vertical_menu {
float: left;
width: 20%;
background-color: #fff;
padding-bottom: 10px;
}
.webwidget_vertical_menu ul{
padding: 0.5px;
margin: 0px;
font-family: Arial, Helvetica, sans-serif;
}
.webwidget_vertical_menu li{
}
.webwidget_vertical_menu ul li{
list-style: none;
position: relative;
}
.webwidget_vertical_menu ul li a{
padding-left: 15px;
text-decoration: none;
}
.webwidget_vertical_menu ul li ul{
display: none;
position: absolute;
background-color: #fff;
z-index: 999999;
}
.webwidget_vertical_menu ul li ul li{
position: relative;
margin: 0px;
border:none;
}
.webwidget_vertical_menu ul li ul li ul{
}
.webwidget_vertical_menu_down_drop{
background-position: right center;
background-repeat:no-repeat !important;
}
.webwidget_vertical_menu ul li li{
font-weight: normal;
}
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background-color: #42413C;
margin: 0;
padding: 0;
color: #000;
}
ul, ol, dl {
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0;
padding-right: 15px;
padding-left: 15px;
}
a img {
border: none;
}
a:link {
color:#414958;
text-decoration: underline;
}
a:visited {
color: #4E5869;
text-decoration: underline;
}
a:hover, a:active, a:focus {
text-decoration: none;
}
.container {
width: 80%;
max-width: 1260px;
background: #FFF;
margin: 0 auto;
}
.header {
background-color: #ADB96E;
}
.sidebar1 {
float: left;
width: 20%;
background-color: #EADCAE;
padding-bottom: 10px;
}
.content {
padding: 10px 0;
width: 60%;
float: left;
}
.sidebar2 {
float: right;
width: 20%;
background-color: #EADCAE;
padding: 10px 0;
}
.content ul, .content ol {
padding: 0 15px 15px 40px; }
ul.nav {
list-style: none;
border-top: 1px solid #666;
margin-bottom: 15px;
}
ul.nav li {
border-bottom: 1px solid #666;
list-style: none;
position:relative;
}
ul.nav a, ul.nav a:visited {
padding: 5px 5px 5px 15px;
display: block;
text-decoration: none;
background-color: #C6D580;
color: #000;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus {
background: #ADB96E;
color: #FFF;
}
/* ~~The footer ~~ */
.footer {
padding: 10px 0;
background: #CCC49F;
position: relative;
clear: both;
}
/* ~~miscellaneous float/clear classes~~ */
.fltrt {
float: right;
margin-left: 8px;
}
.fltlft {
float: left;
margin-right: 8px;
}
.clearfloat {
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
.menu {
color: #414141;
font-size:16px;
font-weight:650;
text-align: center;
}
You don't need the dot (.) in class name.
Try this:
<li><a class='myclass' href="<?php echo base_url();?>index.php/controller">Search</a></li>
And jquery...
// This means select the `<a>` element with class `myclass`.
// Dot (.) means class selector.
$("a.myclass").click(function(){
var link = $(this);
var url = link.attr("href");
$(".content").load(url);
return false;
});
Well, I need more conditions to answer exactly, but I guess there are some css styles for myclass. Try to rename myclass to something like f-ajax-link-selector (don't forget to change it in JS) and try to refresh the page.