hello so i'm trying to make a menu with css but when i try to click on an element from the menu it opens it in a new tab while i want it inside a div in the same page i'm new in css and thats my homework can you help me please and thanks this is the code
<div id="menu"><?php include('admin/Menu/menu.php');?></div>
<div id="main">
i want the content here
</div>
this is the menu code
<ul id="menu">
<li>
<a href="#">Catalogue</a>
<ul>
<li><a href="#">Produits</a></li>
<li><a href="#">Catégories</a></li>
<li><a href="#">Marque</a></li>
<li><a href="#">Fournisseur</a></li>
</ul>
</li>
<li>
<a href="#">Commandes</a>
<ul>
<li><a href="#">Commandes</a></li>
<li><a href="#">Messages prédifinis</a></li>
</ul>
</li>
<li>
<a href="#">Clients</a>
<ul>
<li><a href="#">Clients</a> <li>
<li><a href="#">Pays</a></li>
<li><a href="#">Groupes</a> <li>
<li><a href="#">Titre de civilité</a></li>
</ul>
</li>
<li>
<a href="#">Paramètres avancés</a>
<ul>
<li><a href="#">Emails</a></li>
<li><a href="#">Images</a></li>
</ul>
</li>
<li>
<a href="#">Administration</a>
<ul>
<li><a href="#">Employés</a></li>
<li><a href="#">Profils</a></li>
<li><a href="#">Permission</a></li>
</ul>
</li>
<li>
<a href="#">Stats</a>
<ul>
<li><a href="#">Stats</a></li>
</ul>
</li>
What you could do is either something like this:
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'>
<div id='showMeContent' class='content'>
<p>This is just some basic content</p>
</div>
<div id='showThisContent' class='content'>
<p>This is also just some basic content</p>
</div>
</div>
<style>
.content { display: none; }
#showMeButton:active #showMeContent { display: block; }
#showThisButton:active #showThisContent { display: block; }
</style>
This is the closest you can get using css, but you might be able to do this a little better by using jQuery:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'></div>
<script>
$('#showMeButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is some content</p>");
});
$('#showThisButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is also some content</p>");
});
</script>
Whatever you do, you dó have to make sure you start using id tags, otherwise it just acts as a link, you can easily replace the href='#' with id='something', and then write some css or javascript which opens your content inside the div you'd like it in.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.