i'm having a small issue getting my divs to sit inline with each other and in the center of the parent div. So I have one parent "page" then 6 other divs inside of that the "pageName" which sits above "bg_01", "bg_02", "bg_03", "bg_04", "bg_05", "bg_06" which all sit inline with each other. However it works when the window is quite small however i'm trying to get it to work when the window is any size, can anyone see where I'm going wrong?
Thanks again guys.
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 200px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
#bg_01 {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
float: left;
}
#bg_02 {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
float: left;
}
#bg_03 {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
float: left;
}
#bg_04 {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
float: left;
}
#bg_05 {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
float: left;
}
<div id="page">
<div id="pageName" }>
<p>Colour</p>
</div>
<div id="bg_01">
</div>
<div id="bg_02">
</div>
<div id="bg_03">
</div>
<div id="bg_04">
</div>
<div id="bg_05">
</div>
</div>
Just add text-align: center; to #page and replace float:left; width display: inline-block and it should work.
Something as follows:
<div id="page">
<div id="pageName" }>
<p>Colour</p>
</div>
<div id="bg_01">
</div>
<div id="bg_02">
</div>
<div id="bg_03">
</div>
<div id="bg_04">
</div>
<div id="bg_05">
</div>
</div>
And the css:
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #f00;
width: 100%;
height: 100%;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
#bg_01 {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_02 {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_03 {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_04 {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_05 {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
Here is the fiddle.
Take away Float: left from your objects and give them display: inline-block.
Also give text-align: center to your parent div
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 200px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
#bg_01 {
display: inline-block;
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_02 {
display: inline-block;
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_03 {
display: inline-block;
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_04 {
display: inline-block;
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_05 {
display: inline-block;
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
1) wrap Elments in DIV with class center
<div class="center"> <-------------------
<div id="bg_01">
</div>
<div id="bg_02">
</div>
<div id="bg_03">
</div>
<div id="bg_04">
</div>
<div id="bg_05">
</div>
</div>
2) Remove float: left; and use display:inline block
#bg_01,#bg_02,#bg_03,#bg_04,#bg_05 {
display: inline-block;
float: left;<--------Remove
More code...
}
3) added css For .center :
.center {
text-align: center;
}
Full Code :
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 200px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
#bg_01 {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_02 {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_03 {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_04 {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
#bg_05 {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
display: inline-block;
}
.center {
text-align: center;
}
<div id="page">
<div id="pageName">
<p>Colour</p>
</div>
<div class="center">
<div id="bg_01">
</div>
<div id="bg_02">
</div>
<div id="bg_03">
</div>
<div id="bg_04">
</div>
<div id="bg_05">
</div>
</div>
</div>
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: auto;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
}
#page:after {
content: '';
display: table;
clear: both;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.item {
display: inline-block;
}
#bg_01 {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_02 {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_03 {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_04 {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
#bg_05 {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 4%;
}
<div id="page">
<div id="pageName" }>
<p>Colour</p>
</div>
<div id="bg_01" class="item">
</div>
<div id="bg_02" class="item">
</div>
<div id="bg_03" class="item">
</div>
<div id="bg_04" class="item">
</div>
<div id="bg_05" class="item">
</div>
</div>
p {
margin: 0;
}
#page {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 200px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.center_div{
text-align:center;
margin:20px auto;
display:flex;
justify-content:center;
align-items:center;
}
.common_div{
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin: 3%;
display:inline-block;
}
#bg_01 {
background-color: #80b3ff;
}
#bg_02 {
background-color: #afe9af;
}
#bg_03 {
background-color: #ffb380;
}
#bg_04 {
background-color: #ffaaaa;
}
#bg_05 {
background-color: #eeaaff;
}
<div id="page">
<div id="pageName" >
<p>Colour</p>
</div>
<div class="center_div">
<div id="bg_01" class="common_div">
</div>
<div id="bg_02" class="common_div">
</div>
<div id="bg_03" class="common_div">
</div>
<div id="bg_04" class="common_div">
</div>
<div id="bg_05" class="common_div">
</div>
</div>
</div>
Is this the same that you are looking for?
Hope this helps.
Related
I am trying to make somethng like that:enter image description here
Image from the left I have done without botton-right cut, I have made border-radius.
Image from the right is what happens when you hover on whole item. AS you can see only middle is highlighted. Any idea how to fix it?
Here is my Code:
HTML:
<div class="pojemnik" onclick="location.href='nitystandardowe.html'" >
<div class="zdjecie"> <img src="img/nitystandardowe.jpg"> </div>
<div class="tekst_"><h5>Nity Standardowe</h5> </div>
</div>
CSS:
.pojemnik{
display: flex;
width: 190px;
height: 170px;
background-color: #f5f7f6;
flex-wrap: wrap;
flex-direction: column;
color: silver;
font-family: sans-serif;
text-decoration: none;
border-bottom-right-radius: 30px;
}
.pojemnik:hover {
text-decoration: none;
cursor: pointer;
width: 190px;
height: 190px;
background-position:bottom;
background-image: url("../images/icons/strzalka-w-praw-tlo.png");
background-repeat: no-repeat;
bottom: 20px;
}
.tekst_ {
border-bottom: solid 2px white;
padding-left: 10px;
}
.tekst_:hover {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.tekst_ h5{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
}
.tekst_ h5:hover{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
color: white;
}
.zdjecie{
align-self: flex-start;
}
.zdjecie img{
position: relative;
width: 190px;
}
You need to specify that you also need to target the .tekst_ class upon hover of .pojemnik like so:
.pojemnik:hover .tekst_ {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.pojemnik{
display: flex;
width: 190px;
height: 170px;
background-color: #f5f7f6;
/* flex-wrap: wrap; */
flex-direction: column;
color: silver;
font-family: sans-serif;
text-decoration: none;
border-bottom-right-radius: 30px;
}
.pojemnik:hover {
text-decoration: none;
cursor: pointer;
width: 190px;
height: 190px;
background-position:bottom;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAUVBMVEX///8AAAD7+/s7OzusrKze3t7Z2dmvr6/b29tVVVUFBQVdXV34+Pjt7e0SEhKUlJRCQkLl5eXy8vJzc3NlZWXLy8tra2u9vb1KSkp5eXmZmZlkbd6rAAACfElEQVR4nO2di27aQBBFbWhSYhzCK03T///QVkhR0mAjEyBrn3vOB6C5mjs7uwvLVJWIiIiIiIiIiIiIiIiIiIjIG+1mWzqEW7LYNfU/9s+lA7kRs9f6jeVj6WBuQTuv31ndlQ7nBqzr/+BJ/FN/4r50RFdmu/qssF6Ujum6/DwSSDPqrkMhK4vLLoWoWnzoVEgy6q9uhSCJTz0KOUa971PIkdi91JCMuulViGkaL/0SKUb9wc/iCYmUWuzanOZkMaAWA4waIDHAqAESA4xq05gMARs4mwaB7FoMMCpFYrZRKU0juxYDsmgtToaApuEGjkB206BIzDYqpWlk12JAFgNqMcCoARIDjBogMcCoNo3JELCBs2kQyK7FAKNSJGYb1abRw2xsXDeLm6f9ej42fvcrPLcW29cTnzVSzsri5vjl3AQ4oxYfm9LBfolm+FvinkdXo+dhqMAT7yBGzgs8hXW9HCawLR3nBbSDFN6VDvMChi2nz6XDvIBh/z7BzyG/DvlraUA/nGwSB+9pAval/LPFNM+H515k0M/4B0pfyxzBv23DXwr3Z7BhZBB/5x1sUbzABm9RxiKTXIOMDCa3CXwG6TUI2arhfyqU3CbwAvEWZSwyyRbFZxBfg3iL0gXyT/R4gXSL8gXiLYpv9HiL4jOIr0G8RekC+Vs1xiKTXIOMDCa3CXwG6TXoly/TILlN4AXiLcpYZJItysggft7TiZldDIvy564t4BZNmH/In2HJn0PKnyXLnwfMn+nMn8vNn61eVWuyRQ+08w/6VkCBVTV7f6m6POMN76RY7A6PqvfD/u1horSbbekQRERERERERERERERERERE5Jv4CxOfKflP0w6QAAAAAElFTkSuQmCC");
background-size: 20px 20px;
background-repeat: no-repeat;
bottom: 20px;
}
.tekst_ {
border-bottom: solid 2px white;
padding-left: 10px;
}
/* .tekst_:hover {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
} */
.pojemnik:hover .tekst_ {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.tekst_ h5{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
}
/* .tekst_ h5:hover{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
color: white;
} */
.zdjecie{
align-self: flex-start;
}
.zdjecie img{
position: relative;
width: 190px;
}
<div class="pojemnik" onclick="location.href='nitystandardowe.html'" >
<div class="zdjecie"> <img src="https://cdn.pixabay.com/photo/2020/11/17/15/44/cup-5752775__340.jpg"> </div>
<div class="tekst_"><h5>Nity Standardowe</h5> </div>
</div>
I want to move to the text area to align with other fields and then move all these fields to the down of the text "Feel free...." I was trying to use marigin-left, marigin-top, but nothing works. All the time these fields stay in one place. Do not know why.
It has to work on ip 6/7/8 plus resolution.
Could you tell me how can I achieve it?
* {
margin: 0;
padding: 0;
}
header {
width: 1920;
height: 1080px;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
height: 1080px;
background-image: linear-gradient(180deg, #EFEFEF00 0%, #0F4A37 100%);
}
footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: black;
color: white;
text-align: center;
}
footer img {
margin-top: 5px;
height: 30px;
display: inline-block;
padding: 0px 10px 0px 0px;
}
.main-nav {
float: right;
color: #000000;
margin-top: 40px;
margin-right: 0px;
}
.main-nav li {
display: inline-block;
}
.main-nav li a {
color: #000000;
text-decoration: none;
font: Bold 25px/15px Arial;
padding: 5px;
}
#logo {
margin-top: 10px;
float: left;
}
#tekst {
position: absolute;
}
#sign a {
background-color: #DCDFDE;
padding: 30px 15px 17px 15px;
border-top: 3px solid black;
border-bottom: 3px solid black;
border-left: 3px solid black;
border-right: 3px solid black;
}
#profilesign {
margin-top: 400px;
margin-left: 250px;
font: Bold 40px/40px Georgia;
letter-spacing: 0;
color: black;
}
.left {
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 150px 150px;
}
img.left {
padding: 0px 40px 20px 40px;
width: 250px;
height: 250px;
margin-left: 400px;
margin-top: 500px;
}
article input {
width: 300px;
height: 40px;
background: white;
border-radius: 4px;
text-decoration: none;
text-align: center;
font: Bold 25px/12px Arial;
border-radius: 120;
border-style: none;
padding: 6px;
margin-left: 1000px;
margin-top: 500px;
}
article #textSign {
font-size: 50px;
color: black;
text-align: center;
}
#centerText {
text-align: center;
}
#something {
width: 700px;
height: 300px;
text-align: justify;
margin-left: 1000px;
font-size: 30px;
font-weight: bold;
}
#media only screen and (max-device-width: 500px) {
#profilesign {
width: 1000px;
margin-top: 750px;
margin-left: 400px;
font: Bold 60px/40px Georgia;
letter-spacing: 0;
color: black;
}
img.left {
padding: 0px 40px 20px 40px;
width: 550px;
height: 550px;
margin-left: 550px;
margin-top: 450px;
}
footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
background-color: black;
color: white;
text-align: center;
}
footer img {
margin-top: 5px;
height: 50px;
display: inline-block;
padding: 0px 10px 0px 0px;
}
#sign a {
background-color: #DCDFDE;
padding: 20px 15px 17px 1px;
border-top: 3px solid black;
border-bottom: 3px solid black;
border-left: 3px solid black;
border-right: 3px solid black;
}
#logo img {
margin-left: 550px;
text-align: center;
width: 650px;
}
body {
background-image: linear-gradient(180deg, #EFEFEF00 0%, #0F4A37 100%);
background-size: 100% 3000px;
width: auto;
}
.row {
width: 2500px;
display: grid;
grid-template-columns: 0% 80%;
}
.main-nav {
margin-left: 100px;
margin-top: 250px;
float: left;
display: inline-flex;
list-style: none;
}
.main-nav li a {
border-right: 3px solid black;
color: #000000;
text-decoration: none;
font: Bold 58px/45px Arial;
}
#something {
width: 700px;
height: 300px;
text-align: justify;
margin-top: 200px;
font-size: 30px;
font-weight: bold;
}
article input {
width: 400px;
height: 70px;
background: white;
border-radius: 4px;
text-decoration: none;
text-align: center;
font: Bold 45px/12px Arial;
border-radius: 120;
border-style: none;
padding: 6px;
margin-left: 700px;
}
}
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>DingDog</title>
<link rel="stylesheet" href="css-images/style-contact.css">
</head>
<body>
<header>
<div class="row">
<ul id="logo"> <img src="css-images/dingdog-logo.png"> </ul>
<ul class="main-nav">
<li style="padding-left:10px">PROFILE</li>
<li style="padding-left:10px">MAP</li>
<li style="padding-left:10px">YOUR FRIENDS</li>
<li style="padding-left:10px">MAILBOX</li>
<li style="padding-left:10px" id="sign">LOG OUT</li>
</ul>
</div>
<section>
<article>
<p id="profilesign">Feel free to send us a question.</p>
<img class="left" src="css-images/mial.jpg" style='position:absolute;left:0px; top:0px;' />
<div id="lala">
<p id="centerText">
<label><input type="email" name="email" placeholder="Email" style='margin-top:250px;position:absolute;left:0px; top:0px;' ></label><br/>
<label><input type="name" name="name" placeholder="Name" style="margin-top: 350px; position:absolute;left:0px; top:0px;"></label><br>
<label><input type="subject" name="subject" placeholder='Subject:' style="margin-top: 450px; position:absolute;left:0px; top:0px;"></label><br></p>
<textarea placeholder='Type something' id="something" style="margin-top: 550px; position:absolute;left:0px; top:0px;"></textarea>
</div>
<label id="submit"><input type="submit" name="send" value="Send" style="margin-top: 900px;position:absolute;left:0px; top:0px; background: #2699FB 0% 0% no-repeat padding-box;"></label>
</article>
</section>
</header>
<footer>
<img src="social/instagram.png" />
<img src="social/twitter-white-logo.png" />
<img src="social/facebook.png" />
</footer>
</body>
</html>
I have several nested divs, the last div includes a cross symbol which is supposed to be in the upper right corner. However, it's horizontally centred inside its div and has margins: https://codepen.io/anon/pen/QYEEjg
html:
<div class="content">
<div class="user">
<div class="headline">
<div class="username">some username
<div class='cross'>
<span class='cross-symbol'>
×
</span>
</div>
</div>
<div>
</div>
</div>
css:
.content {
align: center;
width: 660px;
background-color: #c2f0c2;
border: 2px solid black;
}
.user {
text-align: center;
width: 200px;
background-color: gray;
margin: 8px;
border: 1px solid gray;
display: inline-block;
}
.headline {
background-color: silver;
border: 1px solid black;
position: relative;
}
.username {
background-color: orange;
}
.cross {
font-size: 28px;
color: #d00;
font-weight: bold;
font-family: helvetica,arial;
cursor: pointer;
top: 0px;
right: 0px;
outline: 1px solid black;
width: 28px;
height: 25px;
padding: 0px;
position: absolute;
}
.cross-symbol {
top: 0px;
margin: 0px;
padding: 0px;
background-color: green;
vertical-align: bottom;
}
I tried setting padding and margin to 0, but with little result. Any help would be welcome.
Add position:absolute to .cross-symbol and I added line-height
.content {
align: center;
width: 660px;
background-color: #c2f0c2;
border: 2px solid black;
}
.user {
text-align: center;
width: 200px;
background-color: gray;
margin: 8px;
border: 1px solid gray;
display: inline-block;
}
.headline {
background-color: silver;
border: 1px solid black;
position: relative;
}
.username {
background-color: orange;
}
.cross {
font-size: 28px;
color: #d00;
font-weight: bold;
font-family: helvetica,arial;
cursor: pointer;
top: 0px;
right: 0px;
outline: 1px solid black;
width: 28px;
height: 25px;
padding: 0px;
position: absolute;
}
.cross-symbol {
position:absolute;
top: 0px;
margin: 0px;
padding: 0px;
right:0px;
background:green;
line-height:16px;
}
<div class="content">
<div class="user">
<div class="headline">
<div class="username">some username
<div class='cross'>
<span class='cross-symbol'>
×
</span>
</div>
</div>
<div>
</div>
</div>
Please check if this is what you are looking for I have changed html and added some css.. i will description if this is correct. thanks
.content {
align: center;
width: 660px;
background-color: #c2f0c2;
border: 2px solid black;
}
.user {
text-align: center;
width: 200px;
background-color: gray;
margin: 8px;
border: 1px solid gray;
display: inline-block;
}
.headline {
background-color: silver;
border: 1px solid black;
position: relative;
}
.username {
background-color: orange;
}
.cross {
/* font-size: 28px; */
color: #d00;
font-weight: bold;
font-family: helvetica,arial;
cursor: pointer;
top: 50%;
right: 0px;
outline: 1px solid black;
width: 22px;
height: 20px;
/* padding: 0px; */
position: absolute;
transform: translateY(-50%);
}
.cross-symbol {
top: 0px;
margin: 0px;
padding: 0px;
background-color: green;
vertical-align: bottom;
}
.username{
position:realtive;
}
.username p{margin:0}
<div class="content">
<div class="user">
<div class="headline">
<div class="username">
<p>some username</p>
<div class='cross'>
×
</div>
</div>
<div>
</div>
</div>
I'm having a small issue with a couple divs. I have it set up with 5 divs all different colors, when the window size is shrunk the divs drop down under each other one by one. Is there a way I can make the space between them shrinks with it so they but up closer?
Thanks again guys
p {
margin: 0;
}
.pageColourOn {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 155px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pageColourOff {
display: none;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.bg01Off {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg02Off {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg03Off {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg04Off {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg05Off {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.center {
text-align: center;
}
<div class="pageColourOn" id="pageColour">
<div id="pageName">
<p>Colour</p>
</div>
<div class="center">
<div id="bg01" class="bg01Off">
</div>
<div id="bg02" class="bg02Off">
</div>
<div id="bg03" class="bg03Off">
</div>
<div id="bg04" class="bg04Off">
</div>
<div id="bg05" class="bg05Off">
</div>
</div>
Change the container center to a flexbox with the following properties:
.center {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
padding: 0 4%
}
p {
margin: 0;
}
.pageColourOn {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 155px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pageColourOff {
display: none;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.bgOff {
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.bg01Off {
background-color: #80b3ff;
}
.bg02Off {
background-color: #afe9af;
}
.bg03Off {
background-color: #ffb380;
}
.bg04Off {
background-color: #ffaaaa;
}
.bg05Off {
background-color: #eeaaff;
}
.center {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
padding: 0 4%
}
<div class="pageColourOn" id="pageColour">
<div id="pageName">
<p>Colour</p>
</div>
<div class="center">
<div id="bg01" class="bgOff bg01Off">
</div>
<div id="bg02" class="bgOff bg02Off">
</div>
<div id="bg03" class="bgOff bg03Off">
</div>
<div id="bg04" class="bgOff bg04Off">
</div>
<div id="bg05" class="bgOff bg05Off">
</div>
</div>
Add a media query, so that after a certain width of screen the elements will get a margin-bottom that is a percentage instead of px.
Use media queries to make elements respond as the width of the viewport changes for example:
body {
background-color: lightgreen;
}
#media only screen and (max-width: 500px) {
body {
background-color: lightblue;
}
}
This would make the background color change when the width of the viewport goes below 500 px. You can use this same concept with the width of your divs.
** Also, check out Bootstrap. Bootstrap makes it easy to define widths of elements using a grid system. You are trying to make your site "RESPONSIVE" which is a well-known concept in web dev. Bootstrap has an already created library for this problem. It use media queries to do it. It is worth understanding media queries deeply, but for a quick fix, research bootstrap.
You could put a rule in a media query that reduces the margins like in my example (last rule):
p {
margin: 0;
}
.pageColourOn {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 155px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pageColourOff {
display: none;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.bg01Off {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg02Off {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg03Off {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg04Off {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.bg05Off {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 4%;
margin-right: 4%;
display: inline-block;
}
.center {
text-align: center;
}
#media screen and (max-width: 760px) {
.bg01Off,
.bg02Off,
.bg03Off,
.bg04Off,
.bg05Off {
margin-left: 1%;
margin-right: 1%;
}
<div class="pageColourOn" id="pageColour">
<div id="pageName">
<p>Colour</p>
</div>
<div class="center">
<div id="bg01" class="bg01Off">
</div>
<div id="bg02" class="bg02Off">
</div>
<div id="bg03" class="bg03Off">
</div>
<div id="bg04" class="bg04Off">
</div>
<div id="bg05" class="bg05Off">
</div>
</div>
You can use a table instead of the .center div, and give it the following styles:
table {
width: 100%;
text-align: center;
}
td {
width: 20%; /* This is 100/the number of <td>'s you have in the table. */
}
p {
margin: 0;
}
.pageColourOn {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 155px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pageColourOff {
display: none;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.bg01Off {
background-color: #80b3ff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.bg02Off {
background-color: #afe9af;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.bg03Off {
background-color: #ffb380;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.bg04Off {
background-color: #ffaaaa;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.bg05Off {
background-color: #eeaaff;
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
table {
width: 100%;
text-align: center;
}
td {
width: 20%;
}
<div class="pageColourOn" id="pageColour">
<div id="pageName">
<p>Colour</p>
</div>
<table>
<tr>
<td>
<div id="bg01" class="bg01Off">
</div>
</td>
<td>
<div id="bg02" class="bg02Off">
</div>
</td>
<td>
<div id="bg03" class="bg03Off">
</div>
</td>
<td>
<div id="bg04" class="bg04Off">
</div>
</td>
<td>
<div id="bg05" class="bg05Off">
</div>
</td>
</tr>
</table>
You can remove margin left & right and use flexbox on .center like this :
p {
margin: 0;
}
.pageColourOn {
border: 2px solid #e1dfe1;
border-radius: 5px;
background-color: #fff;
width: 100%;
height: 155px;
margin-top: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pageColourOff {
display: none;
}
#pageName {
background-color: #f5f0f5;
border-bottom: 2px solid #e1dfe1;
}
#pageName p {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
color: #565656;
font-weight: bold;
}
.bg01Off {
background-color: #80b3ff;
}
.bg02Off {
background-color: #afe9af;
}
.bg03Off {
background-color: #ffb380;
}
.bg04Off {
background-color: #ffaaaa;
}
.bg05Off {
background-color: #eeaaff;
}
.bg05Off, .bg04Off, .bg03Off, .bg02Off, .bg01Off {
width: 80px;
height: 80px;
border: 3px solid #666;
border-radius: 20px;
margin-top: 10px;
margin-bottom: 10px;
display: inline-block;
}
.center {
display: flex;
justify-content: space-around;
}
<div class="pageColourOn" id="pageColour">
<div id="pageName">
<p>Colour</p>
</div>
<div class="center">
<div id="bg01" class="bg01Off">
</div>
<div id="bg02" class="bg02Off">
</div>
<div id="bg03" class="bg03Off">
</div>
<div id="bg04" class="bg04Off">
</div>
<div id="bg05" class="bg05Off">
</div>
</div>
I have this login form, which works and looks just fine in Chrome, IE11 and Edge but when try it out on Firefox, it looks completely different;
My labels are not the same width, so I have to re-adjust them. Also, my submit button doesn't seem to take on styles.
How can I make this work with Firefox as well?
My HTML:
<div class="loginheader">تسجيل الدخول</div>
<div class="loginform">
<form action="login.php" method="post" name="myform" id="myform">
<p>
<label for="loginform">اسم المستخدم</label>
<input type="text" name="username" id="login" value="mohammed.nasyia#gmail.com" placeholder="اسم المستخدم" />
</p>
<p>
<label for="loginform">كلمة المرور</label>
<input type="password" name="password" id="password" value="mohammed.nasyia#gmail.com" placeholder="كلمة المرور" />
</p>
<p >
<input type="submit" name="submit" value="تسجيل الدخول" class="button admin-login-button"/>
</p>
</form>
</div>
<div class="loginfooter">
تسجيل الدخول كممتحن
</div>
</div>
CSS:
.login-container {
margin-top: 100px;
margin-bottom: 50px;
margin-left: auto;
margin-right: auto;
width: 600px;
}
.loginform {
direction:RTL;
padding: 55px;
background-color: #fff;
border: 1px solid #eee;
border-bottom: 0px;
border-top: 0px;
}
.loginheader {
text-align: center;
background-color: #f5f5f5;
padding: 15px 0px;
border-radius: 10px 10px 0 0;
font-size: 30px;
}
.loginfooter {
padding: 15px 40px;
background-color: #f5f5f5;
border-radius: 0px 0px 10px 10px;
font-size: 18px;
text-align: center;
}
.loginheader, .loginfooter {
background-color: #f5f5f5;
border: 1px solid #ededed;
}
a {
text-decoration: none;
color: #000;
}
input[type=text], input[type=password] {
padding: 0 10px;
width: 320px;
height: 38px;
font-size: 16px;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
}
label {
float: rihgt;
width: 100px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.edit-examinee label{
float: rihgt;
width: 130px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.loginform label {
float: rihgt;
width: 100px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.button {
display: inline-block;
zoom: 1;
padding: 12px 30px;
margin: 0;
cursor: pointer;
border: 1px solid #bbb;
overflow: visible;
font: bold 16px arial, helvetica, sans-serif;
text-decoration: none;
white-space: nowrap;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.admin-login-button {
margin-right: 350px;
color: #333;
background-color: #fff;
border-color: #ccc;
}
.admin-login-button:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
}
.admin-login-button:active {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
position: relative;
top: 2px;
text-shadow: none;
box-shadow: 0 1px 1px rgba(0, 0, 0, .3) inset;
}
You can also check the JSFiddle of the form.
I removed the floats (with a typo), set the margin to left on the .admin-login-button. I also added a media query for smaller screens.
https://jsfiddle.net/6p4v9hs6/7/
New CSS here:
.login-container {
margin-top: 100px;
margin-bottom: 50px;
margin-left: auto;
margin-right: auto;
width: 600px;
}
.loginform {
direction:RTL;
padding: 55px;
background-color: #fff;
border: 1px solid #eee;
border-bottom: 0px;
border-top: 0px;
}
.loginheader {
text-align: center;
background-color: #f5f5f5;
padding: 15px 0px;
border-radius: 10px 10px 0 0;
font-size: 30px;
}
.loginfooter {
padding: 15px 40px;
background-color: #f5f5f5;
border-radius: 0px 0px 10px 10px;
font-size: 18px;
text-align: center;
}
.loginheader, .loginfooter {
background-color: #f5f5f5;
border: 1px solid #ededed;
}
a {
text-decoration: none;
color: #000;
}
input[type=text], input[type=password] {
padding: 0 10px;
width: 320px;
height: 38px;
font-size: 16px;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
}
label {
/* float: rihgt; */
width: 100px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.edit-examinee label{
/* float: rihgt; */
width: 130px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.loginform label {
/* float: rihgt; */
width: 100px;
line-height: 40px;
padding-left: 10px;
font-size: 18px;
text-align: left;
display: inline-block;
margin: 10px 0px;
}
.button {
display: inline-block;
zoom: 1;
padding: 12px 30px;
margin: 0;
cursor: pointer;
border: 1px solid #bbb;
overflow: visible;
font: bold 16px arial, helvetica, sans-serif;
text-decoration: none;
white-space: nowrap;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.admin-login-button {
margin-left: 350px;
color: #333;
background-color: #fff;
border-color: #ccc;
}
.admin-login-button:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
}
.admin-login-button:active {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
position: relative;
top: 2px;
text-shadow: none;
box-shadow: 0 1px 1px rgba(0, 0, 0, .3) inset;
}
#media screen and (max-width: 540px) {
input[type=text], input[type=password] {
width: 90%;
}
}
Seems to work in both Safari and Firefox.