I'm attempting to develop tabbed navigation using my current HTML structure. My goal is to display book titles as tabs and book details BELOW the tabs. Check out this example:
or view this: http://jsfiddle.net/syahrasi/Us8uc/
I cannot change the HTML structure. I am seeking a pure CSS solution, or alternatively, a combination of CSS and jQuery if necessary.
In my current setup (as shown below), clicking on a "book title" tab causes the next tab to shift horizontally. I am in search of a solution that displays the book content beneath the tabs without causing any horizontal shifting of the subsequent tabs.
What I currently have:
$(document).ready(function() {
$('.book-content').hide();
});
$('.btn').click(function(e) {
$('.book-content').hide();
$(this).closest('.book').find('.book-content').slideToggle('fast');
e.preventDefault();
});
body{
background-color: grey;
}
.books{
background-color: white;
}
.book{
display: inline-block;
vertical-align: top;
background-color: lightblue;
}
.hide{
display: none;
}
.active{
background-color:#F7778F;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<title>Document</title>
<link rel="stylesheet" type="text/css" href="stackoverflow.css">
</head>
<body>
<div class="books"> BOOKS <br/>
<div class="book">
<div class="book-title"><a href="" class="btn">Book 1</a></div>
<div class="book-content">
<div class="book-description">Description Lorem ipsum dolor sit amet.</div>
<div class="book-author">Author Lorem ipsum</div>
</div>
</div>
<div class="book active">
<div class="book-title"><a href="" class="btn">Book 2</a></div>
<div class="book-content">
<div class="book-description">Description Lorem ipsum dolor sit amet.</div>
<div class="book-author">Author Lorem ipsum</div>
</div>
</div>
<div class="book">
<div class="book-title"><a href="" class="btn">Book 3</a></div>
<div class="book-content hide">
<div class="book-description">Description Lorem ipsum dolor sit amet.</div>
<div class="book-author">Author Lorem ipsum</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="stackoverflow.js"></script>
</body>
</html>