troubleshooting Question

Positioning with CSS

Avatar of Stefan Motz
Stefan MotzFlag for United States of America asked on
2 Comments1 Solution18 ViewsLast Modified:
Hi Experts,
I would like to modify the position of the tabs with CSS so that it looks like the image on the right.
TabsCurrently the tabs are on the left side, but I'd like to center them and spread out the underline to take the width of the screen. I would appreciate your help.
Please see the code below:
.tabs {
	clear: both;
	position: relative;   
    max-width: 450px;
    margin: 0 auto;


.tab {
	float: left;

.tab label {
	margin-right: 20px;
	position: relative;
	top: 0;
	cursor: pointer;
	color: #000000;

.tab [type=radio] {
	display: none;   

.tab-content {
    position: absolute;
	top: 40px;
	left: 0;
	right: 0;
	bottom: 0;
	transition: all 800ms ease-in-out;
	opacity: 0;


[type=radio]:checked ~ label {
	border-bottom: 4px solid #1d1d1d;
	color: #ff0000;
	font-weight: bold;
	z-index: 2;

[type=radio]:checked ~ label ~ .tab-content {
	z-index: 1;
	opacity: 1;


<div data-tabs class="tabs">    
   <div class="tab">
      <input type="radio" name="tabgroup" id="tab-1" checked>
      <label for="tab-1">Page One</label>
      <div class="tab-content">
         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

   <div class="tab">
      <input type="radio" name="tabgroup" id="tab-2">
      <label for="tab-2">Page Two</label>
      <div class="tab-content">
         Aenean vel elit scelerisque mauris. Porta non pulvinar neque laoreet suspendisse interdum consectetur. Aliquam sem et tortor consequat id porta. Maecenas volutpat blandit aliquam etiam erat velit scelerisque in dictum. Massa tempor nec feugiat nisl pretium fusce id velit. Orci dapibus ultrices in iaculis nunc sed. Facilisis gravida neque convallis a cras semper. Urna id volutpat lacus laoreet non curabitur. Ut morbi tincidunt augue interdum velit euismod in pellentesque. Venenatis lectus magna fringilla urna. In ornare quam viverra orci sagittis eu volutpat odio. 



Open in new window

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros