There is a weird downward shift of the div's on both sides of the page. Definitely something to do with relative and absolute positioning. I've heard a lot about setting the elements width and height when working with position:absolute and relative but no luck.
Is there a better way of positioning these containers inside each other also, all padding and margin is 0px (stated in body tag).
What it's supposed to look like: !https://imgur.com/a/Yol1Kf8
What I have made so far: !https://imgur.com/a/u4zU4iA
CSS:
#mid-section-container {
position: relative;
height: 800px;
width: 100%;
background-color: white;
}
.apps-container {
position: absolute;
height: 617px;
background-color: black;
}
#monthly-leaderboard {
right: 50px;
top: 50px;
}
#tournament-board {
width: 800px;
top: 50px;
left: 50px;
}
.boards-container-nav {
background-color: #363636;
border-bottom: solid 2px #25b6e6;
}
#monthly-leaderboard-header {
height: 85px;
}
#tournament-header {
width: 100%;
height: 85px;
}
.apps-content-container {
height: 80%;
margin: 0px 10px;
background-color: #252525;
border-radius: 7px;
}
#monthly-content {
width: 286px;
}
#tourn-content {
width: 780px;
}
HTML:
<div id="mid-section-container">
<div id="monthly-leaderboard" class="apps-container">
<div id="monthly-leaderboard-header" class="boards-container-nav">
<h1>Monthly Leaderboard</h1>
</div>
<div id="monthly-content" class="apps-content-container">
<div id="monthly-content-header" class="boards-content-nav">
<ul>
<li>Rank</li>
<li>User</li>
<li>Wins</li>
</ul>
</div>
<p>content goes here.</p>
<p>and here.</p>
</div>
</div>
<div id="tournament-board" class="apps-container">
<div id="tournament-header" class="boards-container-nav">
<ul>
<li>Current</li>
<li>Upcoming</li>
</ul>
</div>
<div id="tourn-content" class="apps-content-container">
<div id="tourn-content-header" class="boards-content-nav">
<ul>
<li>Platform</li>
<li>Torunament</li>
<li>Start Time</li>
<li>Teams</li>
</ul>
</div>
</div>
</div>
</div>
Try this one it is help full
#mid-section-container {
position: relative;
height: 800px;
width: 100%;
background-color: white;
}
.apps-container {
position: absolute;
height: 617px;
background-color: black;
}
#monthly-leaderboard {
right: 50px;
top: 50px;
}
#tournament-board {
width: 800px;
top: 50px;
left: 50px;
}
.boards-container-nav {
background-color: #363636;
border-bottom: solid 2px #25b6e6;
}
#monthly-leaderboard-header h1{
margin: 0;
padding: 10px 10px;
color: #FFF;
}
#tournament-header {
width: 100%;
}
.apps-content-container {
height: 80%;
margin: 0px 10px;
background-color: #252525;
border-radius: 7px;
}
#monthly-content {
width: 286px;
}
#tourn-content {
width: 780px;
}
ul li {
display: inline-block;
width: auto;
}
ul li a{
color: #FFF;
}
ul li {
color: #FFF;
}
#tournament-header ul li a{
padding: 10px 20px;
}
#tourn-content-header ul li{
padding: 10px 20px;
}
#monthly-content-header ul li{
padding: 10px 20px;
}
#monthly-content-header{
background-color: #404040;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
#tourn-content-header{
background-color: #404040;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
<div id="mid-section-container">
<div id="monthly-leaderboard" class="apps-container">
<div id="monthly-leaderboard-header" class="boards-container-nav">
<h1>Monthly Leaderboard</h1>
</div>
<div id="monthly-content" class="apps-content-container">
<div id="monthly-content-header" class="boards-content-nav">
<ul>
<li>Rank</li>
<li>User</li>
<li>Wins</li>
</ul>
</div>
<p>content goes here.</p>
<p>and here.</p>
</div>
</div>
<div id="tournament-board" class="apps-container">
<div id="tournament-header" class="boards-container-nav">
<ul>
<li>Current</li>
<li>Upcoming</li>
</ul>
</div>
<div id="tourn-content" class="apps-content-container">
<div id="tourn-content-header" class="boards-content-nav">
<ul>
<li>Platform</li>
<li>Torunament</li>
<li>Start Time</li>
<li>Teams</li>
</ul>
</div>
</div>
</div>
</div>
there is a unnecessary use of position:absolute; i have made changes in your code and removed unwanted css.
#mid-section-container {
position: relative;
height: 800px;
width: 100%;
background-color: white;
display:flex;
}
.apps-container {
height: 617px;
background-color: black;
}
.boards-container-nav {
background-color: #363636;
border-bottom: solid 2px #25b6e6;
}
#monthly-leaderboard-header {
height: 85px;
}
#tournament-header {
width: 100%;
height: 85px;
}
.apps-content-container {
height: 80%;
margin: 0px 10px;
background-color: #252525;
border-radius: 7px;
}
#tournament-board {
width: 70%;
}
#monthly-leaderboard {
width: 30%;
margin-left:20px;
}
<div id="mid-section-container">
<div id="tournament-board" class="apps-container">
<div id="tournament-header" class="boards-container-nav">
<ul>
<li>Current</li>
<li>Upcoming</li>
</ul>
</div>
<div id="tourn-content" class="apps-content-container">
<div id="tourn-content-header" class="boards-content-nav">
<ul>
<li>Platform</li>
<li>Torunament</li>
<li>Start Time</li>
<li>Teams</li>
</ul>
</div>
</div>
</div>
<div id="monthly-leaderboard" class="apps-container">
<div id="monthly-leaderboard-header" class="boards-container-nav">
<h1>Monthly Leaderboard</h1>
</div>
<div id="monthly-content" class="apps-content-container">
<div id="monthly-content-header" class="boards-content-nav">
<ul>
<li>Rank</li>
<li>User</li>
<li>Wins</li>
</ul>
</div>
<p>content goes here.</p>
<p>and here.</p>
</div>
</div>
</div>
Please update following css into your existing css. just add max-width: 1250px; you want. and margin: 0 auto;
#mid-section-container {
position: relative;
height: 800px;
width: 100%;
background-color: white;
max-width: 1250px;
margin: 0 auto;
}
add css
#mid-section-container{
display:flex;
}
#monthly-leaderboard{
width:70%;
height:100%;
}
#tournament-board{
width:30%;
height:100%;
}
also add relevant properties of flex
may be this is the best way to position divs
Related
I’m currently working on a project from Frontend mentor, while developing the mobile version an issue arose where the main section is overflowing onto the footer section.
:root {
--DarkViolet: hsl(256, 26%, 20%);
--Grayish-Blue: hsl(216, 30%, 68%);
--VeryLight-Gray: hsl(0, 0%, 98%);
--Dark-Grayish-Violet: hsl(273, 4%, 51%);
--Very-Dark-Violet: hsl(270, 9%, 17%);
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.hide {
display: none;
}
.content-container {
width: 100%;
padding: 10px 0;
margin: auto;
}
main {
border: 10px dashed red;
display: flex;
flex-direction: column;
}
.flex {
display: flex;
}
.purple {
background-color: var(--DarkViolet);
color: #fff;
}
button {
background-color: var(--DarkViolet);
color: #fff;
border: 2px solid;
padding: 5px 20px;
font-size: .8em;
width: 200px;
}
#media only screen and (min-width: 214px) {
* {
overflow-x: hidden;
}
.content-container {
width: 90%;
}
header {
position: fixed;
background-color: white;
width: 100%;
z-index: 15;
}
header .flex {
flex-direction: row;
justify-content: space-between;
margin-top: 10px;
}
header>* {
padding: 20px;
justify-content: space-between;
}
.menu {
position: fixed;
top: 0;
right: 0;
margin-top: 60px;
background-color: var(--Very-Dark-Violet);
padding: 50px 0;
text-align: center;
height: 100%;
width: 100%;
transform: translateY(-800px);
opacity: 0;
transition: all 0.5s ease-in-out;
}
.menu img {
width: inherit;
position: absolute;
right: 0;
bottom: 0;
}
.menu.open {
overflow: hidden;
opacity: 1;
font-size: 1.3em;
transform: translateY(0px);
transition: all 0.5s ease-in-out;
background-image: url(images/bg-pattern-mobile-nav.svg);
background-position: bottom;
background-repeat: no-repeat;
}
.menu .navLinks {
border: 1px solid gray;
display: block;
list-style: none;
background-color: inherit;
color: #000;
}
.menu .navLinks li {
color: white;
margin: auto;
margin-bottom: 40px;
margin-left: 0;
width: 100%;
}
.menu .navLinks li a {
color: white;
text-decoration: none;
font-size: 1.2em;
text-transform: uppercase;
padding: 0;
margin: 0;
}
.menu .navLinks button {
width: 80%;
font-size: 1.2em;
text-transform: uppercase;
}
main {
transform: translateY(70px);
}
.mobile-intro-img {
width: 100%;
object-fit: fill;
margin-bottom: 0;
}
.purple-big-banner {
border: 3px solid red;
margin: 0;
background-color: var( --Very-Dark-Violet);
color: white;
position: relative;
overflow: hidden;
background-image: url(images/bg-pattern-intro-left-mobile.svg);
background-repeat: no-repeat;
}
.purple-big-banner .mobile-intro-img-left {
position: absolute;
top: 0;
left: 0;
z-index: 100;
}
.purple-big-banner .mobile-intro-img-right {
position: absolute;
bottom: -50%;
z-index: 100;
right: 0;
}
.purple-big-banner .content-container {
border: 3px dashed white;
}
.purple-big-banner .content {
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
gap: 2em;
margin: auto;
padding-top: 60px;
padding-bottom: 60px;
border: 1px solid red;
}
.purple-big-banner button {
margin: auto;
width: 60%;
}
.content-container>.mobile-intro-img-right-continued {
position: absolute;
top: 35%;
right: 0;
}
h1 {
overflow: hidden;
text-align: center;
font-size: 2em;
line-height: .85;
font-family: 'DM Serif Display', serif;
}
.purple-big-banner p {
line-height: 1.4em;
margin: 10px 0;
font-size: 1.1em;
}
hr {
width: 100px;
margin: auto;
margin-top: 40px;
margin-bottom: 20px;
}
.flex {
flex-direction: column;
margin-top: 40px;
align-items: center;
justify-content: center;
}
.box {
margin-bottom: 40px;
border: 1px solid rgb(31, 31, 31);
}
.box img {
padding: auto;
border: 1px solid red;
}
.box>* {
margin-bottom: 20px;
text-align: center;
}
.box p {
color: var(--Grayish-Blue);
}
.small-banner {
border: 5px solid red;
text-align: center;
background-image: url(images/bg-pattern-how-we-work-mobile.svg);
background-color: var( --Very-Dark-Violet);
color: white;
}
.small-banner .content {
display: flex;
flex-direction: column;
gap: 20px;
padding: 40px 0;
}
.small-banner button {
margin: auto;
width: 65%;
}
footer {
background-color: var(--VeryLight-Gray);
background-image: url(images/bg-pattern-footer-mobile.svg);
background-repeat: no-repeat;
border: 3px solid blue;
}
}
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&display=swap" rel="stylesheet">
<header>
<div class="content-container flex">
<img src="images/logo.svg" alt="" srcset="">
<nav class="menu">
<ul class="navLinks">
<li><a class="menuItem" href="#">How we work</a></li>
<li><a class="menuItem" href="#">Blog</a></li>
<li><a class="menuItem" href="#">Account</a></li>
<li><button class="menuItem">View plans</button></li>
</ul>
</nav>
<div class="hamburger ">
<img class="menuIcon" src="images/icon-hamburger.svg " alt="">
<img class="closeIcon hide" src="images/icon-close.svg" alt="">
</div>
</div>
</header>
<main class="flex-main">
<img src="images/image-intro-mobile.jpg" alt="" class="mobile-intro-img-left">
<div class="purple-big-banner">
<div class="content-container">
<div class="content">
<hr class="hide">
<div>
<h1> Humanizing your insurance.</h1>
</div>
<div>
<p>
Get your life insurance coverage easier and faster. We blend our expertise blank and technology to help you find the plan that’s right for you. Ensure you and your loved ones are protected.
</p>
</div>
<div>
<button class="upper">View plans</button>
</div>
</div>
</div>
<img src="images/bg-pattern-intro-right-desktop.svg" class="pattern-right hide" alt="" srcset="">
<img src="images/bg-pattern-intro-left-desktop.svg" class="pattern-left hide" alt="" srcset="">
</div>
<div class="content-container">
<img src="images/bg-pattern-intro-right-mobile.svg" alt="" class="mobile-intro-img-right-continued">
<div class="content">
<hr>
<h1>We’re different</h1>
<div class="flex">
<div class="box">
<div>
<img src="images/icon-snappy-process.svg" alt="">
</div>
<h2>Snappy Process</h2>
<p> Our application process can be completed in minutes, not hours. Don’t get stuck filling in tedious forms.</p>
</div>
<div class="box">
<div>
<img src="images/icon-affordable-prices.svg" alt="">
</div>
<h2> Affordable Prices</h2>
<p> We don’t want you worrying about high monthly costs. Our prices may be low, but we still offer the best coverage possible.</p>
</div>
<div class="box">
<div>
<img src="images/icon-people-first.svg" alt="">
</div>
<h2>People First</h2>
<p> Our plans aren’t full of conditions and clauses to prevent payouts. We make sure you’re covered when you need it.</p>
</div>
</div>
</div>
</div>
<div class="content-container small-banner">
<div class="content">
<div>
<h2>Find out more <br> about how we work</h2>
</div>
<button class="upper">How we work</button>
</div>
</div>
</main>
<footer>
<div class="footer-top">
<div class="content-container flex">
<div class="logo">
<img src="images/logo.svg" alt="" srcset="">
</div>
<div class="flex social">
<ion-icon name="logo-facebook"></ion-icon>
<ion-icon name="logo-twitter"></ion-icon>
<ion-icon name="logo-pinterest"></ion-icon>
<ion-icon name="logo-instagram"></ion-icon>
</div>
</div>
<hr class="content-container">
</div>
<div class="footer-bottom content-container flex">
<div>
<p class="title upper">Our company</p>
<ul>
<li>How we work</li>
<li>Why Insure?</li>
<li>View plans</li>
<li>Reviews</li>
</ul>
</div>
<div>
<p class="title upper">Help me</p>
<ul>
<li>FAQ</li>
<li>Terms of use</li>
<li>Privacy policy</li>
<li>Cookies</li>
</ul>
</div>
<div>
<p class="title upper">Contact</p>
<ul>
<li>Sales</li>
<li>Support</li>
<li>Live chat</li>
</ul>
</div>
<div>
<p class="title upper">Others</p>
<ul>
<li>Careers</li>
<li>Press</li>
<li>Licenses</li>
</ul>
</div>
<div></div>
</div>
<div class="attribution">
Challenge by Frontend Mentor. Coded by Your Name Here.
</div>
</footer>
<script type="module" src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.js"></script>
It seems like this is probably your issue:
main {
transform: translateY(70px);
}
I'm new to .html, self taught, finishing up a website but I'm having some issues with my header.
I have some text that scales on hover, but if part of the text is obscured by the header the text will scale and appear on top of the header, how do I fix this?
I've included a snippet to show what I mean.
/************************** Header *******************/
header {
min-height: 150px;
background: #ccc;
position: fixed;
width: 100%;
}
header ul{
display: inline;
text-align: left;
}
header ul li{
margin-left: 0px;
padding: 2px;
}
header ul li:first-child{
margin-left: 0px;
padding: 2px;
}
header ul li:last-child{
margin-bottom: 30px;
padding: 2px;
}
.spacer{
height: 150px;
}
/********************* Table & Buttons ******************/
.select{
height: 100%;
background-color: #f2f2f2;
padding-top: 35px;
padding-bottom: 35px;
}
.category {
margin: 0 auto;
width: 90%;
border-collapse: collapse;
height: 10%;
background-color: #f2f2f2;
text-align: center;
font-size: xx-large;
}
.mb, .ce{
width: 50%;
}
.mb{
border-right: 2px solid #2F4858;
}
.mb:hover, .ce:hover{
transform: scale(1.1);
transition: transform .2s;
}
.sub{
text-align: center;
font-size: x-large;
width: 100%;
}
.btn {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
}
.spacer2 {
height: 140px;
background: #f2f2f2;
}
<header>
<nav>
<ul>
<li>
<a>Home</a>
</li>
<li class="current">
Portfolio
</li>
<li>
<a>About</a>
</li>
<li>
<a>Contact / Services</a>
</li>
</ul>
</nav>
</header>
<section class="spacer">
</section>
<seciton>
<div class="sub">
<p> Links </p>
</div>
<div class="select">
<table class="category">
<tr>
<td class="mb" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number One</p>
</button>
</td>
<td class="ce" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number Two</p>
</button>
</td>
</tr>
</table>
</div>
</seciton>
<section class="spacer2">
</section>
Using z-index on your header and yours section (be carefull you have wrote seciton one time) did the trick:
/************************** Header *******************/
header {
min-height: 150px;
background: #ccc;
position: fixed;
width: 100%;
z-index: 1; /* ---Set a z-index here--- */
}
header ul{
display: inline;
text-align: left;
}
header ul li{
margin-left: 0px;
padding: 2px;
}
header ul li:first-child{
margin-left: 0px;
padding: 2px;
}
header ul li:last-child{
margin-bottom: 30px;
padding: 2px;
}
.spacer{
height: 150px;
}
/********************* Table & Buttons ******************/
.select{
height: 100%;
background-color: #f2f2f2;
padding-top: 35px;
padding-bottom: 35px;
}
.category {
margin: 0 auto;
width: 90%;
border-collapse: collapse;
height: 10%;
background-color: #f2f2f2;
text-align: center;
font-size: xx-large;
}
.mb, .ce{
width: 50%;
}
.mb{
border-right: 2px solid #2F4858;
}
section {
z-index: 0; /* ---And another here that is lower--- */
}
.mb:hover, .ce:hover{
transform: scale(1.1);
transition: transform .2s;
z-index: 0;
}
.sub{
text-align: center;
font-size: x-large;
width: 100%;
}
.btn {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
}
.spacer2 {
height: 140px;
background: #f2f2f2;
}
<header>
<nav>
<ul>
<li>
<a>Home</a>
</li>
<li class="current">
Portfolio
</li>
<li>
<a>About</a>
</li>
<li>
<a>Contact / Services</a>
</li>
</ul>
</nav>
</header>
<section class="spacer">
</section>
<section>
<div class="sub">
<p> Links </p>
</div>
<div class="select">
<table class="category">
<tr>
<td class="mb" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number One</p>
</button>
</td>
<td class="ce" >
<button class="btn" style="height: 100%;">
<p style="font-size: xxx-large">Button Number Two</p>
</button>
</td>
</tr>
</table>
</div>
</section>
<section class="spacer2">
</section>
⚠️I really recommand you to wrap all your content that is not in the header in a <main></main> component to easily write this type of cleaner css rules:
header {
z-index: 1;
}
main{
z-index: 0;
}
I really need your help with this. For the life of me, I cannot begin to understand as to why I cannot seem to get my form DIV to properly be positioned on the right side of my 2 column layout.
See attached picture below:
Here is the HTML & CSS in question:
* {
font-family: Segoe UI;
font-size: 9pt;
}
html, body {
padding: 0;
margin: 0;
}
body {
background: rgb(187,195,203);
}
.Absolute-Center {
margin: auto;
}
#wrapper {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
#layout {
height: auto;
width: 900px;
border: 1px solid rgb(112,112,112);
}
#box1 {
background: rgb(141,155,169);
color: #FFF;
padding: 3px;
font-weight: bold;
}
#box2 {
width: 100%;
background: rgb(240,240,240);
border-bottom: 1px solid rgb(180,180,180);
padding: 4px;
box-sizing: border-box;
}
#box3 {
width: 100%;
border-bottom: 1px solid rgb(180,180,180);
}
#box4 {
background: #FFF;
float: left;
width: 175px;
height: 375px;
border-right: 1px solid rgb(180,180,180);
}
#box5 {
background: rgb(240,240,240);
height: 375px;
}
#box7 {
background: rgb(240,240,240);
padding: 5px;
text-align:center;
}
#leftcolumn {
float: left;
}
#rightcolumn {
border: 0;
padding: 3px;
text-align: center;
}
.clear {
clear: both;
}
fieldset {
margin: 0;
padding: 2px;
padding-bottom: 5px;
}
div.wrapper {
width: 500px;
}
div.form {
width: 100%;
background-color: rgb(240,240,240);
border: 1px sold #000;
padding: 5px;
}
div.row {
clear: both;
padding-top: 5px;
}
div.row span.label {
float: left;
width: 50px;
text-align: right;
padding-right: 5px;
}
div.row span.formw {
float: left;
width: 200px;
text-align: left;
}
div.spacer {
clear: both;
}
span.title {
color: rgb(70,141,180);
}
input {
width: 150px;
border: 1px solid #000;
}
<div id="wrapper">
<div id="layout" class="Absolute-Center">
<div id="box1">Application Title</div>
<div id="box2">
<div id="leftcolumn"></div>
<div id="rightcolumn"></div>
<div class="clear"></div>
</div>
<div id="box3">
<!-- LEFT WINDOW PANE -->
<div id="box4">
<div id="menu_wrapper">
<ul id="menu">
<li data-show="#1">File Information</li>
<li data-show="#2">Comments</li>
</ul>
</div>
</div>
<!-- RIGHT WINDOW PANE -->
<div id="box5">
<!-- CONTENT [TAB1] -->
<div id="1" style="width: 100%;" class="hidden tab">
<div class="form">
<form>
<div style="border-bottom: 1px solid #000;" class="row"><span class="title">FILE INFORMATION</span></div>
<div class="row">
<span><b>Date Received</b></span>
</div>
<div class="row">
<span class="label">From:</span><span class="formw"><input type="text"/></span>
</div>
<div class="row">
<span class="label">To:</span><span class="formw"><input type="text"/></span>
</div>
<div class="spacer"></div>
</form>
</div>
</div>
<!-- CONTENT [TAB2] -->
<div id="2" class="hidden tab"></div>
</div>
</div>
</div>
</div>
I got it to sit in the right container by adding float:right to the form container div
Fiddle - http://jsfiddle.net/90777hu9/
It's because you float box4 left but you do not float box5 right. So it is still in the flow of the document and pushed below the float left.
Added float:left and width: 78%; to .box5 Press in the snippet the fullpage button to see it
* {
font-family: Segoe UI;
font-size: 9pt;
}
html, body {
padding: 0;
margin: 0;
}
body {
background: rgb(187,195,203);
}
.Absolute-Center {
margin: auto;
}
#wrapper {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
#layout {
height: auto;
width: 900px;
border: 1px solid rgb(112,112,112);
}
#box1 {
background: rgb(141,155,169);
color: #FFF;
padding: 3px;
font-weight: bold;
}
#box2 {
width: 100%;
background: rgb(240,240,240);
border-bottom: 1px solid rgb(180,180,180);
padding: 4px;
box-sizing: border-box;
}
#box3 {
width: 100%;
border-bottom: 1px solid rgb(180,180,180);
}
#box4 {
background: #FFF;
float: left;
width: 175px;
height: 375px;
border-right: 1px solid rgb(180,180,180);
}
#box5 {
background: rgb(240,240,240);
height: 375px;
float:left;
width: 78%;
}
#box7 {
background: rgb(240,240,240);
padding: 5px;
text-align:center;
}
#leftcolumn {
float: left;
}
#rightcolumn {
border: 0;
padding: 3px;
text-align: center;
}
.clear {
clear: both;
}
fieldset {
margin: 0;
padding: 2px;
padding-bottom: 5px;
}
div.wrapper {
width: 500px;
}
div.form {
width: 100%;
background-color: rgb(240,240,240);
border: 1px sold #000;
padding: 5px;
}
div.row {
clear: both;
padding-top: 5px;
}
div.row span.label {
float: left;
width: 50px;
text-align: right;
padding-right: 5px;
}
div.row span.formw {
float: left;
width: 200px;
text-align: left;
}
div.spacer {
clear: both;
}
span.title {
color: rgb(70,141,180);
}
input {
width: 150px;
border: 1px solid #000;
}
<div id="wrapper">
<div id="layout" class="Absolute-Center">
<div id="box1">Application Title</div>
<div id="box2">
<div id="leftcolumn"></div>
<div id="rightcolumn"></div>
<div class="clear"></div>
</div>
<div id="box3">
<!-- LEFT WINDOW PANE -->
<div id="box4">
<div id="menu_wrapper">
<ul id="menu">
<li data-show="#1">File Information</li>
<li data-show="#2">Comments</li>
</ul>
</div>
</div>
<!-- RIGHT WINDOW PANE -->
<div id="box5">
<!-- CONTENT [TAB1] -->
<div id="1" style="width: 100%;" class="hidden tab">
<div class="form">
<form>
<div style="border-bottom: 1px solid #000;" class="row"><span class="title">FILE INFORMATION</span></div>
<div class="row">
<span><b>Date Received</b></span>
</div>
<div class="row">
<span class="label">From:</span><span class="formw"><input type="text"/></span>
</div>
<div class="row">
<span class="label">To:</span><span class="formw"><input type="text"/></span>
</div>
<div class="spacer"></div>
</form>
</div>
</div>
<!-- CONTENT [TAB2] -->
<div id="2" class="hidden tab"></div>
</div>
</div>
</div>
</div>
So I want to add a new part of a website. well its hard to explain... So look at this.
CSS:
.menu-side{
background: #333;
border-right: 1px solid #000;
color: #fff;
position: fixed;
top: 0;
left: -231px;
width: 210px;
height: 100%;
padding: 10px;
}
.menu-side-open{
left:0px;
}
.menu{
overflow-x: hidden;
position: relative;
left: 0px;
}
.menu-open {
left:231px;
}
.menu, .menu-side{
transition: 900ms;
}
.bar {
height: 7px;
width: 25px;
background-color: black;
margin: 2px;
border-radius: 20px;
}
.listing{
text-align: center;
}
.list {
padding: 2px;
color: white;
text-decoration: none;
width: 233px;
}
.list img{
position: absolute;
}
.box:hover {
background-color: gray;
}
body {
background-image: url('download.jpeg')
}
Html:
<header>
<a href="#" class="menu-toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
<nav class="menu-side">
<div class="listing">
<div class="box"><a class="list" href="/"><h1>Home</h1></a> </div>
<div class="box"><a class="list" href="/Photos/"><h1>Photos</h1></a></div>
<div class="box"><a class="list" href="/Store/"><img src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQHEgkUBwgWFgkVFxcbGRgYGSMWHBAeGiQYIiUWHyQfHyosJCYxJxwXIzQtKywsLjEuGCs/OjMsOSg3OjcBCgoKDg0OGxAQGy8kHSQ3LDI3LysvLiwsLi0uNyw0NS83NCw0NCwrNTIsLSwsLDQ0LDQtNCwsLC8yLDctLCwsN//AABEIAEEAQAMBEQACEQEDEQH/xAAcAAEBAQACAwEAAAAAAAAAAAAABwYBCAIDBQT/xAA2EAABAwIBCQQIBwAAAAAAAAABAAIDBBEFBgcSEyExQWFiFEJRsSIjMkORocHRJDVxdIGz4f/EABsBAQACAwEBAAAAAAAAAAAAAAAFBgEDBAcC/8QALhEAAQMDAgUDAwQDAAAAAAAAAAECAwQFERIhIjFBUWFxscFCoeFSgdHwEyMy/9oADAMBAAIRAxEAPwD1VebauweGR9RJFKxnCNzi4Dxs5gvb4qLnpFRNTS6W29xvckMm3ZV9jMArgLKeQK+QeQKGSnZvsttLV02MS+lujkPHpd9CpKkqvoeVK9WbGZ4E9U+UKWpMqQQBAEBLc4eQ2r1lTgsXo75Ixw62/UKNqqX62Fus15ziCdfRfhSaAqOLWarJTJft7opMWvHh+k0C+wzk7mN+66qelV65dyIW53ZtO3RFu/28qfgxbDCJMQkw+kcMOjkLdLeGW2Wv+q1TRYcqtTZDso6tHRxtlcn+RyZx3N1m+y21urpsYl9Zujee90nmuykqs8Dyv3qzaczwJt1T5KQpIqgQBACL79yAlecPIfVaypweL1e+SMcOofZRtVS442Fvs15ziCZd+i/Blcmsa1NTh7sarXmjh0tEG7tXcHd/q1wTq57UeuyHdcKBrYJHQM43YyaOso5co4o3x1nZ8OcbQwjSOs0jbWSaPieJ2bV0va6VvAuG+5EwzQ0U3+1qvkTmv6fCeiGHqYHUj3tmaRI0kfDiFEOarVwpcI5GyNRzeSlNzfZbdo1dPjEvrtzHnv8ASefmpOkqs8DypXqzaMzwJt1Tt5KMpEqoQBAcEXvcbEBKs4eQ/Z9ZU4PF6re9g7vUFGVVLjjaXCzXjViCZd+i/BlMNyhkibSRsIbURnRin0rGFryLtcLWc3jt8F8xVOERvX7HZV2tr5HyKvAu6p1ynZTU5R4ZFXtl1dbpmnY2ONsY03Svdtu4+J2m3ALfUQI5M55e5FWyvdE9G6dnrlVXZERO398GHqqKWhfIyqgc2dli4cWczbdwUW6NzVwpbop45Wo5ioqL9ymZvst+1aumxiT8RuY8+86Tz81JUlVq4Hcyp3qzaMzwJt1Tt59CiKQKsEAQHBGlcOGxAi4JPnDyH7IZKjCIrwHa9g7nUOSjKqmxxNLjZrxrRIJl36L38GTwbG6inYymw2pbHG9/tWDS0usPa4Baoah6Joam69SQrbdTvetRLnDU5J4PfXYuKaJ1PQXL3gdoledN8zh3AT3Ad3iszTI1unm5ea/BrpKJ0kqTO4WNzoanL1X1Pitda1jt8lwk6dmFZTyUIAgCA4c3SBDhcH5oZRcboSTOHkP2IyVGExXpTtewdzqHJRlTTaeNhcrPeElRIJl36L38E+by3KPUsp5Ar5MnZtWU8mCAIAgCA4c0PBDhdp+aGUVUXKEhzhZEHDTJUYTHejO17B7rqHLyUXVU2nibyLpZrwkyJDMvF0Xv+TAgrgLIdnVYzyYIAgCAIAgOHNDwQ8Xad4PFDKKqLlCDZycMiwGubFRbI5YxIG8GkueC0cvRv/KiKqn0LlvIvVmua1EeiX/pNs9/yXpS5RAgCAIAgCAICDZ+fzHD/wBuz+yVc05N2rl+/wDB/9k='><h1>Store</h1></a></div>
</div>
</nav>
</header>
Sorry about the long img src, well ive looked aroung and i found one thing but it didnt work for me. But what i am trying to accomplish is the image in the top right corner. so it would be like an actual banner. I did the position: absolute; but Is there something else? Should i Move the img tag?
Here is a JSFiddle of what I have so far:
JSFiddle Link
html
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 7 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 1 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
</ul>
</div>
css
.answerDiv, .resultDiv, .histogramBar {
display: inline-block;
}
.answerDiv, .histogramBar {
float: left;
}
.answerDiv {
margin-right: 10px;
width: 100px;
}
.histogramBar {
height: 6px;
width: 100px;
background-color: #66dd66;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
}
.histogramBar:hover {
width: 150px;
}
/*text*/
h2 {
font-size: 40px;
color: black;
}
/*alignment*/
.results {
width: 400px;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
I'm having some trouble, however, getting all the alignment stuff right. My goal is to have the text inside the .answerDiv's all float left. If the text was longer, at a certain point it would wrap to a second line. Then, the histogramBar would also float left and sit just to the right of the text. Then, the results number would float right to the opposite side of the containing div. Additionally, I can't figure out how to make the number on the right stay still when the histogramBar's width changes.
Unfortunately, I cannot figure out how to get this to work properly. I'm relatively new to styling so I'm well aware that my code might be really ugly.
How do I accomplish this?
Recap - text floats left, histogram bar floats left (just right of text) numbers float right. when you hover over the bar and it's size changes, the number on the right should not be affected.
For the text to be right-aligned, in you configuration positioning it absolutely based on <li> is the easiest way:
.resultDiv {
text-align: right;
position: absolute;
right: 0;
}
For that to work, you have to add position: relative; to your .resultsListItems.
I changed your example a bit with regard to styling to showcase the elements better.
.answerDiv,
.resultDiv,
.histogramBar {
display: inline-block;
font-size: 14px;
vertical-align: top;
}
.answerDiv {
margin-right: 10px;
width: 100px;
}
.histogramBar {
height: 6px;
width: 100px;
background-color: red;
margin-top: 9px;
border-radius: 5px;
transition: all 1s;
}
.histogramBar:hover {
width: 150px;
}
/*text*/
h2 {
font-size: 40px;
color: black;
}
/*alignment*/
.results {
width: 400px;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
font-size: 0;
}
.resultsListItem {
list-style-type: none;
position: relative;
}
.resultsListItem:nth-of-type(even) {
background-color: #f8f8ff;
}
.results ul {
margin: 0;
padding: 0;
}
.resultDiv {
text-align: right;
position: absolute;
right: 0;
}
<div class="results">
<h2>Some data</h2>
<ul style="">
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">7</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text that will wrap to a new line</div>
<div class="histogramBar"></div>
<div class="resultDiv">821</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">4</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">14</div>
</li>
</ul>
</div>
May this help you.
wrap the class="histogramBar div inside another div. and set the width.
HTML
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv">text</div>
<div class="x">
<div class="histogramBar"></div>
</div>
<div class="resultDiv"> 4</div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv">text</div>
<div class="x">
<div class="histogramBar"></div>
</div>
<div class="resultDiv"> 4</div>
</li>
<br>
</ul>
Sass
$mainColor: #66dd66;
.answerDiv, .resultDiv, .x
{
display: inline-block;
}
.answerDiv, .histogramBar
{
float: left;
}
li div{border:1px solid red}
.answerDiv
{
margin-right: 10px;
width: 100px;
}
.x{width:160px} /*Now .histogramBar is inside .x*/
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
Remove borders and and put the hover on .x
This will fix your numeric text on right and also when you hover on .x it will not affect numeric values.
Do come back if you get any issues.
If it were me, I would do something like this:
$mainColor: #66dd66;
.answerDiv, .resultDiv, .histogramBar
{
display: inline-block;
border:1px solid red;
}
.results
{
border:1px solid red;
}
.answerDiv, .histogramBar
{
float: left;
}
.answerDiv
{
margin-right: 10px;
width: 100px;
}
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
.resultDiv
{
}
.resultsListItem
{
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.answersListItem
{
position:relative;
top:30px;
left:20px;
width:100px;
border:1px solid red;
float:left;
}
.histogramListItem
{
position:relative;
top:10px;
left:50px;
width:100px;
height:72px;
border:1px solid red;
float:left;
}
.resultListItem
{
position:relative;
top:-10px;
float:right;
border:1px solid red;
width:10px;
margin-right:50px;
}
<html>
<body>
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="answersListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
</li>
<br>
<li class="histogramListItem" style="list-style-type: none;">
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
</li>
<br>
<li class="resultListItem" style="list-style-type: none;">
<div class="resultDiv"> 7 </div>
<div class="resultDiv"> 1 </div>
<div class="resultDiv"> 4 </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
</ul>
</div>
</body>
</html>
check the Updated fiddle. https://jsfiddle.net/e1xrwyLv/4/
If I clearly understood your problem then following css should resolve your problem.
CSS
$mainColor: #66dd66;
.resultsListItem{
margin-bottom:5px;
&:after{
clear:both;
content:'';
display:block;
}
}
.answerDiv, .resultDiv, .histogramBar
{
display: inline-block;
}
.answerDiv, .histogramBar
{
float: left;
}
.answerDiv
{
margin-right: 10px;
width: auto;
max-width:200px
}
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
.resultDiv
{
float:right;
}
.resultsListItem
{
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}