This is my div structure. I'm having difficulties achieving the following.
How can I make all 3 buttons (Sub 1, Sub 2, Sub 3) visible and make the height of DIV 1 to the height of its children buttons?
Fiddle
html:
.sub {
position: relative;
background-color: lime;
}
.itmHolder {
position: relative;
}
.Buttons {
display: inline-block;
padding: 12px 8px;
}
.itmHolder:nth-child(2),
.itmHolder:nth-child(3) {
position: absolute;
top: 0;
}
.og {
margin-top: 15px;
position: relative;
text-align: center;
}
<div class="og">
<div class="itmHolder">
<div class="sub">DIV 1</div>
<div class="sub">DIV 2</div>
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
</div>
<div class="itmHolder">
<button type="button" class="normalBtn">Button</button>
</div>
</div>
Expected output:
well I removed obsolete elements and css definitions and now it looks exactly like the image:
.sub {
position: relative;
background-color: lime;
overflow: hidden;
}
.itmHolder {
position: relative;
}
.Buttons {
display: inline-block;
padding: 12px 8px;
}
.og {
margin-top: 15px;
position: relative;
text-align: center;
}
<div class="row">
<div class="og">
<div class="itmHolder">
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
</div>
<div class="itmHolder">
<button type="button" class="normalBtn">Button</button>
</div>
</div>
</div>
fiddle
You just have to change your css a little:
.Buttons{
display: inline-block;
padding: 1px 8px;
height: 100%;
line-height: 100%;
}
.itmHolder > :nth-child(2) , .itmHolder > :nth-child(3){
position: absolute;
top:0;
width: 100%;
}
https://jsfiddle.net/t5au23ra/7/
I would have made somethin like that
.wrapper {
width: 500px;
text-align: center;
margin: 0 auto;
}
.subs {
background-color: green;
}
.subs button {
height: 30px;
}
<div class="wrapper">
<div class="subs">
<button>Sub1</button>
<button>Sub2</button>
<button>Sub3</button>
</div>
<button>Button</button>
</div>
Your problem and your markup is not understandable. Don't know why you have used pos:abs property. If you want as in your figure then, you don't need that much codes. Look at this fiddle .
HTML
<div class="make-center">
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
<button type="button" class="normalBtn">Button</button>
</div>
CSS
.make-center {
text-align: center;
padding: 20px 0;
}
.sub {
background: lime;
}
.normalBtn,
.Buttons {
padding: 10px;
border: 1px solid gray;
}
The spacing between buttons are because of default button border ( browser's default rendering ).
i hope you want like this type of menu
<ul class="itmHolder">
<li>DIV 1</li>
<li>DIV 2
<ul class="sub">
<li> <button type="button" class="Buttons">Sub 1</button></li>
<li> <button type="button" class="Buttons">Sub 2</button></li><li>
<button type="button" class="Buttons">Sub 3</button></li>
<button type="button" class="normalBtn">Button</button>
</ul>
</li>
</ul>
css
.itmHolder{ margin:0; padding:0;}
.itmHolder li{ display:inline-block; position:relative;}
.itmHolder li .sub{display:none; height:50px; background:lime; width:100%; position:absolute; width:500px;}
.itmHolder li:hover .sub {display:block;}
.itmHolder li:hover .sub button{height:50px; margin:0 2px;}
.normalBtn{top:50px;margin-left:250px;position:absolute}
use this.
Remove this from your css: Demo
.itmHolder :nth-child(2) , .itmHolder :nth-child(3){
position: absolute;
top:0;
}
As per your expected output. This could help you.
HTML
<div>
<div class="parent">
<button>SUB1</button>
<button>SUB2</button>
<button>SUB3</button>
</div>
<div>
<button>Button</button>
</div>
</div>
CSS
.parent {
background-color: lime;
}
div{
text-align: center;
}
.parent button{
margin: 0;
padding:0;
height: 55px;
width: 50px;
}
Related
The code when ran doesn't fill the flexbox like I would like it to do, and I want to continue to be more so responsive to size changes. I have pulled resources from a lot of places and still can't find out why it isn't working. I came here because I often use this site to help with other work as well.
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
/* Header */
.column, .columna, .columnab, .columnb {
align-items: center;
text-align: center;
border: solid;
border-width: thin;
max-height: 20em;
}
.column {
flex: 33%;
}
.columna {
width: 100%;
}
.columnab {
width: 22%;
}
.columnb {
width: 17%;
}
.row {
min-height: 10em;
display: flex;
flex-wrap: wrap;
background-color: #FF9176;
}
/* Navigation Section */
.dropbtn {
background-color: #FF9176;
color: #0061A0;
font-size: 75%;
font-family: 'Solway', serif;
padding: 16px;
border: none;
cursor: pointer;
}
.dropbtn:hover, .dropbtn:focus {
background-color: #FEB384;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
width: 100%;
position: absolute;
background-color: #FEB384;
min-width: 160px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #FECE9D;}
.show {display: block;}
<header>
<div class="row">
<div class="column" style="padding: 0">
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 1</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 2</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 3</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 4</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
</div>
<div class="column">
<h6> LOGO </h6>
<img src="images/print_studio_logo.***" alt="Print Studio's Logo">
</div>
<div class="column" style="padding: 0">
<div class="columna" style="height: 50%;">
<h6> INSERT CART / LOGIN </h6>
</div>
<div class="columna" style="height: 50%;">
<h6> INSERT SOCIAL </h6>
</div>
</div>
</div>
</header>
Welcome to stack overflow. Your question is not very clear could you be more precised about the element you would like to fill, by pointing classes or maing img.
For now I adjusted the width of your dropdown class that were not by 100%
.dropdown{
width: 100%;
}
.dropdown button {
width: 100%;
}
DEMO based on what I understood.
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
/* Header */
.column, .columna, .columnab, .columnb {
align-items: center;
text-align: center;
border: solid;
border-width: thin;
max-height: 20em;
}
.column {
flex: 33%;
}
.columna {
width: 100%;
}
.columnab {
width: 22%;
}
.columnb {
width: 17%;
}
.row {
min-height: 10em;
display: flex;
flex-wrap: wrap;
background-color: #FF9176;
}
/* Navigation Section */
.dropbtn {
background-color: #FF9176;
color: #0061A0;
font-size: 75%;
font-family: 'Solway', serif;
padding: 16px;
border: none;
cursor: pointer;
}
.dropbtn:hover, .dropbtn:focus {
background-color: #FEB384;
}
.dropdown {
position: relative;
display: inline-block;
width:100%;
}
.dropdown-content {
display: none;
width: 100%;
position: absolute;
background-color: #FEB384;
min-width: 160px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #FECE9D;}
.dropdown button{ width:100%;}
.show {display: block;}
<header>
<div class="row">
<div class="column" style="padding: 0">
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 1</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 2</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 3</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
<div class="columna">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">GROUP 4</button>
<div id="myDropdown" class="dropdown-content">
Item 1
Item 2
Item 3
</div>
</div>
</div>
</div>
<div class="column">
<h6> LOGO </h6>
<img src="images/print_studio_logo.***" alt="Print Studio's Logo">
</div>
<div class="column" style="padding: 0">
<div class="columna" style="height: 50%;">
<h6> INSERT CART / LOGIN </h6>
</div>
<div class="columna" style="height: 50%;">
<h6> INSERT SOCIAL </h6>
</div>
</div>
</div>
</header>
I am building a Electron app of which layout would be like this:
| header bar |
|col 1| col 2| col 3|
| bottom bar |
There would be 3 columns in the main view between the fixed top and bottom bar while the 3 columns are y-scrollable and each of them has a separate html embedded.
This is the html and SCSS code of my layout but all the columns stick to the top and hidden by the header bar and the bottom bar didn't even show up.
Any idea to fix this? Thanks!
HTML
<body>
<div id="top-bar" class="row h-15">
app title
</div>
<div class="container-fluid">
<div id="main-screen" class="row">
<div id="main-col-1" class="col-4 main-col">
<button id="btn-img-1" type="button" class="btn btn-img btn-lg">btn 1</button>
</div>
<div id="main-col-2” class="col-4 main-col">
<button id="btn-img-2” type="button" class="btn btn-img btn-lg">btn 2</button>
</div>
<div id="main-col-3” class="col-4 main-col">
<button id="btn-img-3” type="button" class="btn btn-img btn-lg">btn 3</button>
</div>
</div>
</div>
<div id="bottom-bar" class="row h-20 text-center" style="margin-bottom:0">
</div>
</body>
SCSS
html {
}
body {
min-width: map-get($base, width);
background-color: map-get($base, background);
overflow-x: hidden;
}
#main-screen{
display:block;
position:relative;
}
.main-col{
padding: 0em;
height: 100%;
color: #3d02bd;
overflow-y:scroll;
}
#main-col-1{
background-color: #e25bff;
}
#main-col-2{
background-color: #ddb1ff;
}
#main-col-3{
background-color: #fbefff;
}
.btn-img{
color: #ffffff;
background-color:#3d02bd;
}
#top-bar {
position: fixed;
left: 0;
top: 0;
width: 100%;
margin-bottom: 0;
background-color: #2a095f;
color:#ffffff;
border: 0;
font-size: 3.5em;
letter-spacing: 0.1em;
opacity: 0.9;
}
#bottom-bar {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
margin-bottom: 0;
background-color: #3d02bd;
color:#ffffff;
border: 0;
font-size: 2.5em;
letter-spacing: 0.1em;
}
Check This code
also change ” to "
html {
}
body {
min-width: map-get($base, width);
background-color: map-get($base, background);
overflow-x: hidden;
}
#main-screen{
display:block;
position:relative;
}
.main-col{
padding: 0em;
height: 100%;
color: #3d02bd;
width:33.33%;
float:left;
overflow-y:scroll;
}
#main-col-1{
background-color: #e25bff;
}
#main-col-2{
background-color: #ddb1ff;
}
#main-col-3{
background-color: #fbefff;
}
.btn-img{
color: #ffffff;
background-color:#3d02bd;
}
#top-bar {
width: 100%;
margin-bottom: 0;
background-color: #2a095f;
color:#ffffff;
border: 0;
font-size: 3.5em;
letter-spacing: 0.1em;
opacity: 0.9;
margin-bottom:15px;
}
#bottom-bar {
width: 100%;
text-align: center;
margin-bottom: 0;
background-color: #3d02bd;
color:#ffffff;
border: 0;
font-size: 2.5em;
letter-spacing: 0.1em;
margin-top:15px;
display:inline-block;
}
<div id="top-bar" class="row h-15">
app title
</div>
<div class="container-fluid">
<div id="main-screen" class="row">
<div id="main-col-1" class="col-4 main-col">
<button id="btn-img-1" type="button" class="btn btn-img btn-lg">btn 1</button>
</div>
<div id="main-col-2" class="col-4 main-col">
<button id="btn-img-2" type="button" class="btn btn-img btn-lg">btn 2</button>
</div>
<div id="main-col-3" class="col-4 main-col">
<button id="btn-img-3" type="button" class="btn btn-img btn-lg">btn 3</button>
</div>
</div>
</div>
<div id="bottom-bar" class="row h-20 text-center" style="margin-bottom:0">bottom bar
</div>
I'm trying to set my navbar to be on top whenever I scroll, but when i use position: fixed; the navbar disappears. Here's my html and css respectively.
<nav>
<div class="navbar">
<button class="btn button"> Home <A href="#"> </button>
<button class="btn button"> About Me </button>
<button class="btn button"> Portfolio</button>
<button class="btn button"> Contact Me </button>
</div>
</nav>
<div class="background-img">
</div>
<div class="portfolio">
<img src="https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjP5v6bzfDWAhXEto8KHc_gBDoQjRwIBw&url=http%3A%2F%2Fhomequity.us%2Fdesignhouse%2Fbungalow_house_design_malaysia.html&psig=AOvVaw3hVzFHYi5ropXAhSrn1oIx&ust=1508087256948636">
</div>
The CSS
nav{
background-color: transparent;
position: fixed;
}
.btn{
background-color: Black;
color: white;
font-size: 30px;
padding: 10px;
margin: 10px 193px 10px 0px;
}
.background-img {
background: url(https://images.unsplash.com/photo-1497215842964-222b430dc094?dpr=1&auto=compress,format&fit=crop&w=2100&h=&q=80&cs=tinysrgb&crop=);
background-size: 100% 100%;
background-repeat: no-repeat;
width: 100vw;
height: 100vh;
position: relative;
}
`
You still need to define it's fixed position as top:0.
nav{
background-color: transparent;
position: fixed;
top:0;
width:100%;
z-index:15;
}
The reason is z-index value. And one more thing you probably forget to close the a tag in nav section.
nav{
background-color: transparent;
position: fixed;
z-index:99999; /* add z-index value maximum */
}
.btn{
background-color: Black;
color: white;
font-size: 30px;
padding: 10px;
margin: 10px 193px 10px 0px;
}
.background-img {
background: url(https://images.unsplash.com/photo-1497215842964-222b430dc094?dpr=1&auto=compress,format&fit=crop&w=2100&h=&q=80&cs=tinysrgb&crop=);
background-size: 100% 100%;
background-repeat: no-repeat;
width: 100vw;
height: 100vh;
position: relative;
}
<nav>
<div class="navbar">
<button class="btn button"> Home </button><!-- You need to close the a tag -->
<button class="btn button"> About Me </button>
<button class="btn button"> Portfolio</button>
<button class="btn button"> Contact Me </button>
</div>
</nav>
<div class="background-img">
</div>
<div class="portfolio">
<img src="https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjP5v6bzfDWAhXEto8KHc_gBDoQjRwIBw&url=http%3A%2F%2Fhomequity.us%2Fdesignhouse%2Fbungalow_house_design_malaysia.html&psig=AOvVaw3hVzFHYi5ropXAhSrn1oIx&ust=1508087256948636">
</div>
I'm currently trying to create a special hover for a website.
Here is what I'm trying to do :
4 blocks, all responsive with a black bar with 70% of opacity with the main text.
Then when I hover a block, the black bar fill all the space at the bottom and reveals 2 or 4 buttons.
Maybe something like this :
<div class="image-block">
<div class="image1">
<span class="black-bar">SOME TEXT</span>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
<div class="image2">
<span class="black-bar">SOME TEXT</span>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
<div class="image3">
<span class="black-bar">SOME TEXT</span>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
<div class="image4">
<span class="black-bar">SOME TEXT</span>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
</div>
But for the CSS I really don't know how to do this. What is the simplest and best way to do this with something fully responsive ?
Thanks !
Here's a pure css option. If I missed something just let me know. I had to adjust your markup a little bit.
.image-block{
display: flex;
flex-direction: row;
}
.col{
display: flex;
flex-direction: column;
}
.image1, .image2, .image3, .image4{
background: url(http://lorempixel.com/output/nature-q-c-640-480-1.jpg) no-repeat center center;
background-size: cover;
width: 200px;
margin: 0 20px 20px 0;
position: relative;
overflow: hidden;
}
.image1, .image4{
height: 100px;
}
.image2, .image3{
height: 200px;
}
.black-bar{
background: rgba(0,0,0,0.4);
text-align: center;
color: #fff;
width: 100%;
top: 50%;
position: absolute;
margin-top: -18px;
padding: 10px 0;
font-family: Helvetica, Arial, sans-serif;
transition: all 0.5s ease;
bottom: calc(50% - 15px);
overflow: hidden;
}
.black-bar button{
margin: 10px;
display: none;
border: none;
background: #fff;
}
.black-bar p{
margin: 0;
font-weight: 200;
font-size: 12px;
}
.image1:hover .black-bar, .image2:hover .black-bar, .image3:hover .black-bar, .image4:hover .black-bar{
bottom: 0;
transition: all 0.5s ease;
}
.image1:hover .black-bar button, .image2:hover .black-bar button, .image3:hover .black-bar button, .image4:hover .black-bar button{
display: inline-block;
}
<div class="image-block">
<div class="col">
<div class="image1">
<div class="black-bar">
<p>SOME TEXT</p>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
</div>
<div class="image2">
<div class="black-bar">
<p>SOME TEXT</p>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
</div>
</div>
<div class="col">
<div class="image3">
<div class="black-bar">
<p>SOME TEXT</p>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
</div>
<div class="image4">
<div class="black-bar">
<p>SOME TEXT</p>
<button class="special-button">Button</button>
<button class="special-button">Button</button>
</div>
</div>
</div>
</div>
Edit:
Added an animation via tiny bit of calc magic.
bottom: calc(50% - 15px);
Check out the code below (I had to use jQuery) or this fiddle
$('.text').mouseenter(function () {
$('.hovering').animate({'height': '200px'}, 'slow');
});
$('.image').mouseleave(function () {
$('.hovering').animate({'height': '100px'}, 'slow');
});
.image {
position: relative;
background-image: url(http://www.w3schools.com/css/trolltunga.jpg);
height: 300px;
width: 600px;
}
.hovering {
display: block;
height: 100px;
width: 600px;
background-color: rgba(0,0,0,0.7);
overflow: hidden;
margin-top: 100px;
position: absolute;
}
button, .text {
display: block;
width: 130px; height: 40px;
margin: 0 auto;
}
.text {
color: white;
font-size: 40px;
text-align: center;
padding-top: 30px;
width: 200px;
margin-bottom: 30px;
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="image">
<div class="hovering">
<span class="text">Text here</span>
<button>Button here</button>
</div>
</div>
The black box shrinks when mouse leaves the image
So, my parent DIV contains 3 main DIV which contain a couple DIVs each. I have the parents li elements displayed inline as I want all 3 nested DIVs to be side by side along the width of the parent. I have been successful with getting the first two lined up correctly. The third div has the correct x-axis positioning however on the y-axis it has dropped down and outside of the parent div and I'm not sure where I am going wrong. I have tried many many different solutions on StackOverflow, however, none have had any success.
I have the right-hand div (the one below parent) set to absolute as if it's not then it does not get the correct x-axis, with absolute it gets half the position correct.
Relevant code:
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: none;
margin-right: 5px;
width: 201px;
padding-left: 238px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
margin-top: 24px;
position: absolute;
width: 233px;
left: 0;
}
.wrapper .rightSide {
float: right;
position: absolute;
width: 273px;
left: 445px;
/*top:88px;*/
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
And a screen-grab of the output of the code:
Sorry for the sloppy code I'm new to this. If you could tell me where I've gone wrong but also why it's gone wrong and why the solution will fix it I'd be grateful as it will aid my learning.
Cheers and thanks in advance.
You are messing it up with position:absolute. Check the solution below.
Just update:
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
Try this
Jsfiddle
Give .supMid property display: inline-block
.supMid{
float:none;
display: inline-block;
margin-right:5px;
width:201px;
padding-left:238px;
}
Just give vertical-align:top to .rightSide. No need of position to set element
.wrapper .rightSide {
float: right;
width: 250px;
vertical-align: top;
}
Try to change some of their properties. I used float instead of position
.wrapper .leftSide {
margin-top: 24px;
float: left;
width: 233px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .rightSide {
float: left;
width: 273px;
}