I'm unable to move the submit button to the left 1vw without disturbing the anchor tags in the right. Also, there's plenty of room in the anchor borders but I can't get the text and image to stay on the same line when decreasing the width of the browser.
UPDATE: was able to keep img and text on same line in anchor by changing anchor display:block to display:inline-flex.
Still unable to move the submit buttom to the right without disturbing the anchor tags
#footer-top{
background-color:white;
padding: 0 2.87rem;
}
h3{
color:#b3d7f8;
font-size: 1.5vw;
padding-top:3vw;
padding-left:2vw;
background-color:#538231;
margin:0
}
#footer-container{
padding: 0 2.87rem;
background-color:white;
}
.myFooter{
background-color:white;
display: flex;
flex-wrap: nowrap;
}
.myFooter .left{
flex: 1 1 auto;
background-color:#538231;
padding-top:3vw;
padding-left:2vw;
padding-bottom:2vw;
}
.myFooter label{
display: block;
color: #c2d59b;
margin-bottom:1vw;
font-size:1vw;
}
.myFooter input{
padding: .5vw .5vw;
}
#email{
height:1vw;
line-height:1;
font-size:1vw;
width:25vw;
}
.submit-button {
background-color: white!important;
border: none!important;
color: black!important;
padding: .5vw .5vw!important;
text-align: center!important;
text-decoration: none!important;
display: inline-block!important;
font-size: 1vw!important;
height:2vw!important;
width:5vw!important;
line-height:1vw!important;
}
.myFooter .right{
flex: 1 1 ;
background-color:#538231;
padding-bottom:2vw;
}
.myFooter .right a{
display: inline-flex;
color: white;
border: 1px solid white;
width: 71%;
margin: 1vw 0;
text-decoration:none;
}
.myFooter .right img{
width: 1.5vw;
height: 100%;
padding: .59vw 0;
display:block;
float:left;
margin:0 1vw;
}
.myFooter .right span{
font-size:1vw;
padding:1vw 0;
display:inline-block;
line-height:1;
}
#media screen and (max-width: 961px) {#footer-top,#footer-container{
padding:0 1.7rem;}
}
<div id ="footer-top">
<h3>Help create a sustainable and healthy town of Weston</h3>
</div>
<div id="footer-container">
<div class="myFooter">
<div class="left">
<form name="message" method="post">
<section>
<label for="email">Join our mailing list:</label><input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</section>
</form>
</div>
<div class="right">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png">
<span class="foot-txt">Like us on Facebook</span>
</a>
<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png">
<span class="foot-txt">follow us on Instagram</span>
</a>
<a href="https://twitter.com/Weston_SWAG">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png">
<span class="foot-txt">Retweet us on Twitter</span>
</a>
</div>
</div>
<div>
Since your .left and .right elements have flex-grow: 1 applied (via the flex shorthand) they have expanded across all free space and are touching. So anything that changes the width of one element will impact the other.
First thing I would suggest is to get rid of that rule and instead use justify-content: space-between on the container.
Then, prevent the anchors on the right from wrapping by giving them white-space: nowrap. Also remove the width limitation so the text doesn't overflow.
#footer-top {
background-color: white;
padding: 0 2.87rem;
}
h3 {
color: #b3d7f8;
font-size: 1.5vw;
padding-top: 3vw;
padding-left: 2vw;
background-color: #538231;
margin: 0
}
#footer-container {
padding: 0 2.87rem;
background-color: white;
}
.myFooter {
/* background-color: white; */
background-color: #538231; /* adjustment */
display: flex;
flex-wrap: nowrap;
justify-content: space-between; /* new */
}
.myFooter .left {
/* flex: 1 1 auto; */
background-color: #538231;
padding-top: 3vw;
padding-left: 2vw;
padding-bottom: 2vw;
}
.myFooter label {
display: block;
color: #c2d59b;
margin-bottom: 1vw;
font-size: 1vw;
}
.myFooter input {
padding: .5vw .5vw;
}
#email {
height: 1vw;
line-height: 1;
font-size: 1vw;
width: 25vw;
}
.submit-button {
background-color: white !important;
border: none !important;
color: black !important;
padding: .5vw .5vw !important;
text-align: center !important;
text-decoration: none !important;
display: inline-block !important;
font-size: 1vw !important;
height: 2vw !important;
width: 5vw !important;
line-height: 1vw !important;
margin-left: 5px; /* change values here; right anchors don't move anymore */
}
.myFooter .right {
/* flex: 1 1; */
background-color: #538231;
padding-bottom: 2vw;
padding-right: 2vw; /* new */
}
.myFooter .right a {
display: block;
color: white;
border: 1px solid white;
/* width: 71%; */
margin: 1vw 0;
text-decoration: none;
white-space: nowrap; /* new */
padding-right: 2vw; /* new */
}
.myFooter .right img {
width: 1.5vw;
height: 100%;
padding: .59vw 0;
display: block;
float: left;
margin: 0 1vw;
}
.myFooter .right span {
font-size: 1vw;
padding: 1vw 0;
display: inline-block;
line-height: 1;
}
#media screen and (max-width: 961px) {
#footer-top,
#footer-container {
padding: 0 1.7rem;
}
}
<div id="footer-top">
<h3>Help create a sustainable and healthy town of Weston</h3>
</div>
<div id="footer-container">
<div class="myFooter">
<div class="left">
<form name="message" method="post">
<section>
<label for="email">Join our mailing list:</label><input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</section>
</form>
</div>
<div class="right">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png">
<span class="foot-txt">Like us on Facebook</span>
</a>
<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png">
<span class="foot-txt">follow us on Instagram</span>
</a>
<a href="https://twitter.com/Weston_SWAG">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png">
<span class="foot-txt">Retweet us on Twitter</span>
</a>
</div>
</div>
<div>
jsFiddle demo
Related
I have two big problems:
The first trouble I have encountered is that when I am testing the responsivity of my website in the contact section I always meet a reappearing problem: There is a white space (.2 rem - 1.2rem width) on the right side of the body when I try to display the whole page under 400px width device.
My second problem is that I have social media icons in the footer. They appear properly in all other sections (multipage website), but only here does something prevent them to be displayed properly. I tried resizing their main divs to 100% width and 100% max-width, but an element is probably still longer than the others, which should obviously cause this kind of problem.
So about the white blank area, I think it is important to know that I have a specially styled scrollbar, which might also cause this little mischief. I am unsure, so I have also tried removing it, but it did not help. In the beginning, I also encountered the same problem with the footer, but somehow I managed to get by and was able to solve it by correcting the width of the .footer-container. Since then the white space appeared and my second problem with social media icons not being displayed properly just arose.
Here is my code:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="contacts.css">
<title>Eckert Művek Galéria</title>
</head>
<body>
<div class="floating-btn show-btn" aria-label="up button" role="button">
<img src="assets/svg_files/chevron-up-solid.svg" alt="up img" />
</div>
<header>
<!--NAVBAR-->
<nav>
<ul class="menu" id="desktop-menu">
<li class="nav-item">Főoldal</li>
<li class="nav-item">Rólunk</li>
<li class="nav-item">Szolgáltatások</li>
<li class="nav-item">Miért mi?</li>
<li class="nav-item">Galéria</li>
<li class="nav-item">Kapcsolat</li>
</ul>
<!--HAMBURGER ICON-->
<div class="header-right-gap">
<button class="hamburger" aria-label="hamburger button">
<div class="line line-1"></div>
<div class="line line-2"></div>
<div class="line line-3"></div>
</button>
</div>
</nav>
<!--MOBILE MENU-->
<div class="mobile-menu">
<ul class="m-menu">
<li class="nav-item">Főoldal</li>
<li class="nav-item">Rólunk</li>
<li class="nav-item">Szolgáltatások</li>
<li class="nav-item">Miért mi?</li>
<li class="nav-item">Galéria</li>
<li class="nav-item">Kapcsolat</li>
</ul>
</div>
</header>
<main>
<!--CONTACT FORM-->
<div class="container">
<form>
<h1>Kapcsolat</h1>
<input type="text" id="firstName" placeholder="Családnév" required>
<input type="text" id="lastName" placeholder="Keresztnév" required>
<input type="email" id="email" placeholder="Email" required>
<input type="text" id="mobile" placeholder="Telefonszám" required>
<h4 class="contactus">Lépjen velünk kapcsolatba!</h4>
<textarea id="texti" required></textarea>
<input type="submit" value="Elküldés" id="button">
</form>
</div>
</main>
<footer>
<div class="footer-container">
<!--COMPANY INFORMATION, CONTATCTS-->
<div class="footer-top">
<div>
<article>
<h2>Elérhetőségeink</h2>
<div class="cellphone">
<img src="assets/png/telephone.png" alt="phone-icon">
<h3><span>Telefonszám:</span> +36709424298</h3>
</div>
<div class="internet">
<img src="assets/png/mail.png" alt="email-icon">
<h3><span>E-mail:</span> eckertmuvek#gmail.com</h3>
</div>
<div class="headquarter">
<img src="assets/png/location.png" alt="company-icon">
<h3><span>Telephely:</span> Budapest, 1182 Török Bálint u. 16/b</h3>
</div>
<div class="opening-hours">
<img src="assets/png/clock.png" alt="op-icon">
<h3><span>Nyitvatartási idő:</span> hétfő - péntek(7:00 - 17:30)</h3>
</div>
</article>
</div>
<!--TEXT-->
<div class="text-container">
<h4>Céginformációk</h4>
<p>
<ol>
<li>
<h5>Cégjegyzékszám: </h5>
<p> 01 09 996342</p>
</li>
<li>
<h5>Adószám: </h5>
<p>24222716243</p>
</li>
<li>
<h5>Számlaszám: </h5>
<p>112131423-43242142-432412421</p>
</li>
<li>
<h5>Cégnév: </h5>
<p>Eckert Művek Korlátolt Felelősségű Társaság</p>
</li>
</ol>
</p>
</div>
<!--
<div class="text-container">
<h4>Ttitle-1</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
Dicta modi laborum quibusdam quis natus debitis qui dolor
voluptatibus ab sit, cum saepe enim unde doloribus veniam
numquam perspiciatis optio impedit.</p>
</div>
-->
<!--POLICIES-->
<div class="policies">
Impresszum
GDPR Tájékoztató
Süti Tájékoztató
</div>
</div>
<!--MAP-->
<div class="map">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2699.366130757782!2d19.217992451587673!3d47.42430370844346!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4741c1f21fa88e89%3A0x44673b68b84b51c9!2zQnVkYXBlc3QsIFTDtnLDtmsgQsOhbGludCB1LiAxNmIsIDExODI!5e0!3m2!1shu!2shu!4v1672662477180!5m2!1shu!2shu"
height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
</div>
<!--SOCIAL MEDIA ICONS-->
<div class="social-media-icons">
<div class="sm-container" id="insta">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="github">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="facebook">
<div class="sm-icon">
</div>
</div>
<div class="sm-container" id="linkedin">
<div class="sm-icon">
</div>
</div>
</div>
<div class="footer-bottom">
<p>© Eckert Művek Kft. Minden jog fenntartva.</p>
</div>
</div>
</footer>
<script src="contacts.js"></script>
</body>
</html>
And here is my CSS code:
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#100;200;300;400;500;600;700;800;900&display=swap');
:root {
--nav-height: 100px; /*80%*/
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
}
html {
scroll-behavior: smooth;
}
body {
min-height: 100vh;
width: 100%;
font-size: 12px;
font-family: sans-serif;
}
.floating-btn {
position: fixed;
bottom: 3.5vh;
right: 0;
width: 50px;
height: 50px;
z-index: 100;
background-color: yellow;
border-radius: 50%;
padding: 10px;
box-shadow: 0 0 5px hsla(0, 0%, 0%, hsla(0,0%,0%,0.5));
cursor: pointer;
margin-right: 1rem;
border: 1px solid #000;
}
.show-btn {
display: block;
}
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100px;
z-index: 100;
background-color: #000;
}
/*Srcollbar*/
::-webkit-scrollbar{
width: 15px;
background: #000;
}
::-webkit-scrollbar-thumb {
background: yellow;
border-radius: 10px;
border: 1px solid black;
}
::-webkit-scrollbar-thumb:active {
background: orangered;
}
nav {
display: flex;
width: min(90%, 1200px);
height: inherit;
align-items: center;
justify-content: flex-start;
margin-inline: unset;
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 20px;
left: 2.5rem;
gap: 1rem;
/*margin-top: -2.5rem;*/
}
nav a {
max-height: var(--nav-height);
align-items: center;
margin-inline: auto;
font-size: 20px;
position: relative;
height: 100%;
}
nav ul {
display: flex;
gap: 1rem;
width: 100%;
list-style: none;
margin-top: 3rem;
}
.nav-item a {
color: white;
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
font-size: 20px;
height: 100%;
margin: .5em .8em;
padding: 10px;
}
.nav-item a::before,
.nav-item a::after {
content: '';
height: 14px;
width: 14px;
position: absolute;
transition: all .35s ease;
opacity: 0;
}
nav a::before {
content: '';
right: 0;
top: 0;
border-top: 3px solid #ffed4b;
border-right: 3px solid #fdcd3b;
transform: translate(-100%, 50%); /*-100%, 50%*/
}
.nav-item a:after {
content: '';
left: 0;
bottom: 0;
border-bottom: 3px solid #fdcd3b;
border-left: 3px solid #ffed4b;
transform: translate(100%, -50%); /*100%, -50%*/
}
.nav-item a:hover:before,
.nav-item a:hover:after{
transform: translate(0,0);
opacity: 1;
}
.nav-item a:hover {
text-decoration: underline;
color:yellow;
}
.container{
min-height: 100vh;
width: 99.vw;
background: #08071d;
display: flex;
justify-content: center;
align-items: center;
background: url("assets/images/mainpage/106811484-1608045351058-gettyimages-1126750618-dsc_1540.jpeg") no-repeat center center/cover;
}
.container form{
width: 670px; /*670px*/
height: 450px;
display: flex;
justify-content: center;
box-shadow: 20px 20px 50px rgba(0,0,0,0.5);
border-radius: 15px;
background: rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
flex-wrap: wrap;
overflow-x: hidden;
}
.container form h1{
color: #fff;
font-weight: 500;
margin-top: 20px;
width: 500px;
text-align: center;
}
.container form input{
width: 290px;
height: 40px;
padding-left: 10px;
outline: none;
border: none;
font-size: 25px;
margin-bottom: 10px;
background: none;
border-bottom: 2px solid #fff;
}
.container form input::placeholder{
color: #ddd;
}
.container form #lastName,
.container form #mobile{
margin-left: 20px;
}
.container form h4{
color: #fff;
font-weight: 300;
width: 600px;
margin-top: 20px;
}
.container form textarea{
background: none;
border: none;
border-bottom: 2px solid #fff;
color: #fff;
font-weight: 200;
font-size: 25px;
padding: 10px;
outline: none;
min-width: 600px;
max-width: 600px;
min-height: 80px;
max-height: 80px;
}
.contactus {
font-size: 18px;
}
input[type="text"]:focus, input[type="email"]:focus, #texti:focus {
border-bottom: 3px solid #fdcd3b;
}
textarea::-webkit-scrollbar{
width: 1em;
}
textarea::-webkit-scrollbar-thumb{
background-color: rgba(194,194,194,0.713);
}
.container form #button{
border: 1px solid;
background: transparent;
border-radius: 50px;
margin-top: 20px;
font-weight: 600;
font-size: 20px;
color: #fff;
width: 100px;
padding: 0;
margin-right: 500px;
margin-bottom: 30px;
transition: 0.3s;
}
.container form #button:hover{
opacity: 0.9;
transform: scale(1.2);
background-color: black;
color: yellow;
}
/*FOOTER*/
footer {
width: 100%;
background-color: #000;
padding-block: 4rem;
color: white;
}
.footer-container {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-inline: auto;
width: min(90%, 1200px);
}
.footer-top {
width: 100%;
height: 100%;
color: #fff;
font-size: 10px;
display: flex;
justify-content: space-around;
}
.footer-top h2 {
text-align: center;
justify-content: center;
align-items: center;
}
.footer-top article div {
line-height: 2.5rem;
}
.footer-top article div:first-of-type {
margin-top: 1rem;
}
.footer-top img {
height: 64px;
}
.text-container p {
margin-top: 2rem;
}
.text-container ol li {
line-height: 1.5rem;
}
/*CONTACT ICONS*/
.cellphone img, .internet img, .headquarter img, .opening-hours img{
background-color: yellow;
border-radius: 50px;
transition: all 0.3s linear;
}
footer img:hover {
background-color: orangered;
border-radius: 40px;
transform: rotate(-360deg);
}
.footer-bottom {
text-align: center;
margin-top: 2rem;
}
span {
color: yellow;
}
.text-container {
justify-content: space-between;
width: 20vw;;
font-size: 0.8rem;
}
/*POLICIES LINKS*/
.policies {
display: flex;
flex-direction: column;
font-size: 14px;
text-transform: uppercase;
}
.policies a {
color: yellow;
font-size: 10px;
line-height: 2rem;
}
.policies a:hover {
color: orangered;
}
/*MAP*/
.map {
margin-inline: auto;
}
/*SOCIAL MEDIA ICONS*/
.social-media-icons {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.sm-container {
display: flex;
justify-content: center;
gap: 2rem;
padding:1rem;
border: 1px black;
width: 100%;
height: 100%;
}
.sm-container a:active {
color: yellow;
}
.fa {
border-radius: 50%;
width: 100%;
height: 100%;
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: 30px;
/**/
}
.fa-instagram {
background: #125688;
color: white;
padding: 1rem;
}
.fa-github {
background: white;
color: black;
padding: 1rem;
}
.fa-facebook {
background: #4267B2;
color: white;
padding: 1rem;
}
.fa-linkedin {
background: #3B5998;
color: white;
padding: 1rem;
}
.sm-icon {
transition: all 0.3s linear;
}
.sm-icon:hover {
transform: scale(1.2);
}
.fa:hover {
background-color: #fdcd3b;
}
/*MOBILE MENU*/
.mobile-menu {
display: none;
}
.mobile-menu {
display: flex;
width: 100%; /*.line a szülő tehát 40px a width*/
height: calc(100vh - 80px);
align-items: center;
justify-content: center;
position: absolute;
top: 80px;
left: 0;
background-color: black;
transform: translate(-100%);
transition: all 0.4s ease;
z-index: 100;
}
.mobile-menu-on {
display: flex; /**/
transform: translate(0);
}
.m-menu {
display: flex;
flex-direction: column;
gap: 2rem;
text-align: center;
font-size: 1.4rem;
}
/*hamburger icon*/
.header-right-gap {
width: 100px;
margin-left: 2rem;
}
.hamburger {
display: none;
position: fixed;
width: 50px;
height: 50px;
border: none;
background-color: transparent;
top: 0;
left: 1;
margin-top: 1.5rem;
}
.hamburger:hover {
border: 6px solid;
border-color: yellow;
width: 43px;
margin-left: 4px;
transform: scale(1.2);
}
.hamburger:hover .line.line-1 {
/*display: none;*/
transform: rotate(45deg) translateY(7.5px);
background-color: yellow;
}
.hamburger:hover .line.line-2 {
display: none;
}
.hamburger:hover .line.line-3 {
/*display: none;*/
transform: rotate(-45deg) translateY(-7.5px);
background-color: yellow;
}
.line {
transition: all .4s ease;
width: 40px;
height: 5px;
background-color: white;
margin-block: 5px;
border-radius: 10px;
}
/*Media query*/
#media (max-width: 1200px) {
.hamburger {
display: block;
}
#desktop-menu {
display: none;
}
}
#media (max-width: 900px) {
footer nav ul {
flex-direction: column;
}
footer nav ul li a {
font-size: 15px;
/*padding: 15px;*/
}
}
#media (max-width: 750px) {
.footer-container {
display: flex;
flex-wrap: wrap;
}
footer nav ul li a {
font-size: 10px;
padding: 15px;
}
.text-container p {
font-size: 10px;
}
}
#media (max-width: 600px) {
.container form {
width: 470px;
}
.container form input {
width: 160px;
}
.container form #button, .container form h4 {
margin-inline: auto;
}
.container form textarea {
min-width: 300px;
max-width: 300px;
}
}
#media (max-width: 400px) {
.container {
max-width: 100%;
height: 100%;
overflow: hidden;
}
.container form {
max-width: 100%;
padding-top: 40px;
padding-bottom: 10px;
}
.container form input, h4 {
text-align: center;
}
.container form input {
width: 160px;
}
.container form #button, .container form h4 {
margin-inline: auto;
}
.container form textarea {
align-items: center;
min-width: 300px;
max-width: 300px;
}
.text-container {
width: 70vw;
}
.container form #button {
display: flex;
flex-direction: column;
}
footer {
width: 400px;
}
.footer-top {
display: flex;
flex-direction: column;
align-items: center;
}
}
I once had a similar problem and it was due to margin of one element being bigger than it should be, and it just made that div bigger and pushed it out of viewport, so you could check your margins, I can see that you have quite a lot of margins, inline and to margin-right as well.
I'm trying to set up 2-columns that are responsive (e.g., collapse with one on top of the other). The left column has text and the right has some buttons.
I want both to center align with each other vertically within the container. However, when I test for responsiveness, my buttons overflow out of the container instead of wrapping with the 2nd column:
.boxContent {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.boxCol {
flex: 0 0 50%;
box-sizing: border-box;
padding-right: 75px;
}
a.boxBtn {
display: block;
padding: 0.35em 1.2em;
border: 0.1em solid #1e1e1e;
margin: 0 0.3em 0.3em 0;
border-radius: 2%;
box-sizing: border-box;
text-decoration: none;
background-color: #fff;
text-align: left;
transition: all 0.2s;
}
.boxBtn:hover {
color: #000;
background-color: #e5bc73;
cursor: pointer;
}
#media all and (max-width: 30em) {
a.boxBtn {
margin: 0.4em auto;
}
}
#media screen and (max-width: 800px) {
.boxCol {
flex: 0 1 100%;
padding-right: 0;
padding-bottom: 75px;
}
}
<div class="Container">
<div class="boxContent">
<div class="boxCol">
<h1>Heading</h1>
</div>
<div class="boxCol">
<a class="boxBtn">
Button 1
</a>
<a class="boxBtn">
Button 2
</a>
<a class="boxBtn">
Button 3
</a>
</div>
</div>
</div>
from my comment :
you need either to reset flex-direction or allow wrapping on smaller screen. Your media queries do not reset any of them rules
If it is only to pile them without reordering purpose, display reset is good enough ,
possible example:
.boxContent {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.boxCol {
flex: 0 0 50%;
box-sizing: border-box;
padding-right: 75px;
}
a.boxBtn {
display: block;
padding: 0.35em 1.2em;
border: 0.1em solid #1e1e1e;
margin: 0 0.3em 0.3em 0;
border-radius: 2%;
box-sizing: border-box;
text-decoration: none;
background-color: #fff;
text-align: left;
transition: all 0.2s;
}
.boxBtn:hover {
color: #000;
background-color: #e5bc73;
cursor: pointer;
}
#media all and (max-width: 30em) {
a.boxBtn {
margin: 0.4em auto;
}
}
#media screen and (max-width: 800px) {
.boxContent {display:block;}
}
<div class="Container">
<div class="boxContent">
<div class="boxCol">
<h1>Heading</h1>
</div>
<div class="boxCol">
<a class="boxBtn">
Button 1
</a>
<a class="boxBtn">
Button 2
</a>
<a class="boxBtn">
Button 3
</a>
</div>
</div>
</div>
Tip: another approach would be to trigger the flex display at min-width:800px only, before no need for a 1 column layout.
I know this has been asked in this forum many times, but I read every topic about it and tried many suggested solutions and still, I'm not able to make it work for my own case.
Here's this case. I have this grid of content cards, but depending on the length of the content or whether or not every element in the card is used, the card has a different height. So, elements are not aligned from one card to another. I'd like to edit my code so the top of each element starts at a relative height so they are aligned.
Codepen: https://codepen.io/louischausse/pen/VRQxgB
I'd like that top of each child div align with each other
Thanks for your help
.section__etudes-card > span, [gr-grid~=row--block], .section__featured-article .hs_cos_wrapper .widget-module ul {
position: relative;
display: -ms-flexbox;
-js-display: flex;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-left: -15px;
margin-right: -15px;
align-items: stretch;}
.section__etudes-card > span > div, [gr-grid=block], .section__featured-article .hs_cos_wrapper .widget-module ul li {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
max-width: 100%;
padding-left: 15px;
padding-right: 15px;
margin-top: 30px; }
.section__etudes-card {
margin-top: 1.875rem;
margin-bottom: 1.875rem; }
.section__etudes-card > span > div {
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%; }
#media (min-width: 48em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 33%;
flex-basis: 33%;
max-width: 33%; } }
#media (min-width: 64em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
max-width: 25%; } }
.section__etudes-card > span > div:empty {
display: none; }
.etude-card {
display: block;
text-align: center;
margin-bottom: 0.9375rem;
text-decoration: none; }
#media (min-width: 64em) {
.etude-card:hover [class*="btn--"] {
/*transform: scale(1.05);*/
color: #fff;
background-color: #e98815;
border-color: #e98815; } }
.etude-card .etude-card__title {
margin-top: 0.9375rem;
margin-bottom: 0.9375rem;
font-weight: bold;
color: #333333;
line-height: 1.1; }
.etude-card .etude-card__date {
font-size: 0.8125em;
margin-top: 0.625rem;
margin-bottom: 0.625rem; }
.etude-card .etude-card__ufc {
color: #FFFFFF;
font-size: .75em;
padding: 3px 8px;
background-color: #e98815;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card .etude-card__cost {
color: #e98815;
font-size: .75em;
padding: 3px 8px;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card [class*="btn--"] {
padding-left: .5em;
padding-right: .5em;
text-transform: none; }
.etude-card img {
width: 100%;
max-width: 215px;
margin-left: auto;
margin-right: auto; }
.etude-card__ufc:empty {
display: none; }
.etude-card__cost:empty {
display: none; }
.btn--primary {
padding: 10px 35px;
font-size: 16px;
border-radius: 5px;
display: inline-block;
position: relative;
z-index: 0;
text-decoration: none;
text-transform: none !important;
color: #FFFFFF;
background-color: #e98815;
border: 2px solid transparent;
}
.btn--primary:hover {
background: #ffffff !important;
color: #e98815 !important;
border: 2px solid #e98815 !important;
}
<section class="section__etudes-card">
<span id="hs_cos_wrapper_Ressource_center_element" class="hs_cos_wrapper hs_cos_wrapper_widget_container hs_cos_wrapper_type_widget_container" style="" data-hs-cos-general-type="widget_container" data-hs-cos-type="widget_container"><div id="hs_cos_wrapper_widget_1552502647360" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1552496573108" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS A VERY MUCH LONGER EVENT TITLE CAUSING PROBLEMS
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1551887999614" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888011972" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888047237" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
</section>
Is here what you want :
All the events title aligned
All the tag aligned
The button always at the bottom
What you will need
All the card having the same height
The card being a flex column
For mor clarity, I'll add the necessary css at the end of your css.
.section__etudes-card > span > div {
display: flex; /* Necessary for the cards to have the same height */
}
.etude-card {
display: flex; /* Necessary for the cards to have the same height */
flex-direction: column; /* To be able to push the childrens down */
width: 100%;
}
.etude-card > :nth-child(3) {
margin-top: auto; /* Will push the first tag down */
}
.etude-card__date:nth-last-child(3) {
margin-top: auto; /* Will push everything starting with the date down */
}
.section__etudes-card > span, [gr-grid~=row--block], .section__featured-article .hs_cos_wrapper .widget-module ul {
position: relative;
display: -ms-flexbox;
-js-display: flex;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-left: -15px;
margin-right: -15px;
align-items: stretch;}
.section__etudes-card > span > div, [gr-grid=block], .section__featured-article .hs_cos_wrapper .widget-module ul li {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
max-width: 100%;
padding-left: 15px;
padding-right: 15px;
margin-top: 30px; }
.section__etudes-card {
margin-top: 1.875rem;
margin-bottom: 1.875rem; }
.section__etudes-card > span > div {
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%; }
#media (min-width: 48em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 33%;
flex-basis: 33%;
max-width: 33%; } }
#media (min-width: 64em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
max-width: 25%; } }
.section__etudes-card > span > div:empty {
display: none; }
.etude-card {
display: block;
text-align: center;
margin-bottom: 0.9375rem;
text-decoration: none; }
#media (min-width: 64em) {
.etude-card:hover [class*="btn--"] {
/*transform: scale(1.05);*/
color: #fff;
background-color: #e98815;
border-color: #e98815; } }
.etude-card .etude-card__title {
margin-top: 0.9375rem;
margin-bottom: 0.9375rem;
font-weight: bold;
color: #333333;
line-height: 1.1; }
.etude-card .etude-card__date {
font-size: 0.8125em;
margin-top: 0.625rem;
margin-bottom: 0.625rem; }
.etude-card .etude-card__ufc {
color: #FFFFFF;
font-size: .75em;
padding: 3px 8px;
background-color: #e98815;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card .etude-card__cost {
color: #e98815;
font-size: .75em;
padding: 3px 8px;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card [class*="btn--"] {
padding-left: .5em;
padding-right: .5em;
text-transform: none; }
.etude-card img {
width: 100%;
max-width: 215px;
margin-left: auto;
margin-right: auto; }
.etude-card__ufc:empty {
display: none; }
.etude-card__cost:empty {
display: none; }
.btn--primary {
padding: 10px 35px;
font-size: 16px;
border-radius: 5px;
display: inline-block;
position: relative;
z-index: 0;
text-decoration: none;
text-transform: none !important;
color: #FFFFFF;
background-color: #e98815;
border: 2px solid transparent;
}
.btn--primary:hover {
background: #ffffff !important;
color: #e98815 !important;
border: 2px solid #e98815 !important;
}
/* The changes: */
.section__etudes-card > span > div {
display: flex;
}
.etude-card {
display: flex;
flex-direction: column;
width: 100%;
}
.etude-card > :nth-child(3) {
margin-top: auto;
}
.etude-card__date:nth-last-child(3) {
margin-top: auto;
}
<section class="section__etudes-card">
<span id="hs_cos_wrapper_Ressource_center_element" class="hs_cos_wrapper hs_cos_wrapper_widget_container hs_cos_wrapper_type_widget_container" style="" data-hs-cos-general-type="widget_container" data-hs-cos-type="widget_container"><div id="hs_cos_wrapper_widget_1552502647360" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1552496573108" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS A VERY MUCH LONGER EVENT TITLE CAUSING PROBLEMS
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1551887999614" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888011972" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888047237" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
</section>
This question already has answers here:
Setting the width of inline elements
(7 answers)
Closed 4 years ago.
I am trying to design a form so, that the input fields are among themselves. I tried it by giving the labels before the input-fields a width so that even if the label-text is shorter, space is the same. It worked in a youtube video, but I can't get it working for some reason. Whichever width I give it to the label, nothing changes. I guess it's a really simple error made by me, which gets me hardly frustrated.
body,
html {
background-color: aquamarine;
background-image: url(../background.jpg);
height: 100%;
overflow-y: hidden;
margin: 0;
}
#Wrapper {
margin-left: 15%;
margin-right: 15%;
height: 100vh;
}
/*
************************************************
Hier beginnt das Header-Styling"
************************************************
*/
header {
position: relative;
background-color: blueviolet;
margin: 0;
display: flex;
justify-content: space-between;
align-items: center;
flex: 0 1 60%;
padding: 0 1rem;
border-radius: 0em 0em 1em 1em;
height: 56px;
}
header img {
width: 2.5em;
height: 2.5em;
}
#branding {
position: absolute;
left: 2em;
margin: 0;
margin-left: 0.3em;
font-family: 'Yanone Kaffeesatz', sans-serif;
color: lawngreen;
}
.nav {
display: flex;
flex: 0 1 25%;
justify-content: space-between;
align-items: center;
}
.navitem {
list-style: none;
}
.navitem a {
font-size: 20px;
margin-top: 0;
color: black;
text-decoration: none;
font-family: 'Anton', sans-serif;
}
.navitem a {}
.navitem a:hover {
color: rgba(0, 0, 0, 0.6);
cursor: pointer;
}
/*
************************************************
Header-Styling ENDE
************************************************
*/
main {
display: flex;
flex-direction: column;
align-items: center;
width: 80%;
height: calc(100vh - 56px);
background-color: white;
margin: 0;
margin-right: auto;
margin-left: auto;
overflow-y: auto;
border: 1px solid Maroon;
border-top: 0px;
}
main h2 {
margin: 1em;
font-family: 'Anton', sans-serif;
}
main h4 {
font-size: 2em;
}
/*
************************************************
Hier beginnt das Tabellen-Styling"
************************************************
*/
table {
padding: 1em;
background-color: lightgray;
}
table tr {}
table th {
font-size: 1.5em;
}
table td {
font-weight: 700;
text-align: center;
border-right: 1px solid gray;
border-bottom: 1px solid gray;
padding: 3em;
}
table td:last-child {
border-right: 0px;
padding: 0.3em;
}
td img {
height: 11em;
width: 11em;
}
/*
************************************************
Tabellen-Styling ENDE
************************************************
*/
/*
************************************************
Hier beginnt das Formular Styling
************************************************
*/
form {
padding: 8em;
background-color: slategray;
}
.forms label {
width: 2em;
}
<link href="https://fonts.googleapis.com/css?family=Anton|Baloo+Bhaijaan|Gloria+Hallelujah|PT+Sans+Narrow|Righteous|Titillium+Web|Yanone+Kaffeesatz" rel="stylesheet">
<div id="Wrapper">
<header>
<img src="logo.png">
<h1 id="branding">Einfache-Rezepte</h1>
<ul class="nav">
<li class="navitem active">Startseite</li>
<li class="navitem">Rezepte</li>
<li class="navitem">Kontakt</li>
</ul>
</header>
<main>
<form action="mailto:Email" method="post">
<h3>Kontaktiere uns!</h3>
<div class="forms">
<label for="vname">Vorname:</label>
<input type="text" id="vname" name="Vorname">
</div>
<div class="forms">
<label for="nname">Nachname:</label>
<input type="text" id="nname" name="Nachname">
</div>
<div class="forms">
<label for="msg">Ihre Nachricht:</label>
<textarea name="nachricht" cols="40" rows="10"></textarea>
</div>
<input type="submit" value="Absenden">
<input type="reset" value="Zurücksetzen">
</form>
</main>
</div>
CodePen: https://codepen.io/anon/pen/qJeQNe
You are missing display:inline-block; on label style. By default label elements are inline and to assign a width you need to change it to inline-block.
Check the Snippet below:
body,
html {
background-color: aquamarine;
background-image: url(../background.jpg);
height: 100%;
overflow-y: hidden;
margin: 0;
}
#Wrapper {
margin-left: 15%;
margin-right: 15%;
height: 100vh;
}
/*
************************************************
Hier beginnt das Header-Styling"
************************************************
*/
header {
position: relative;
background-color: blueviolet;
margin: 0;
display: flex;
justify-content: space-between;
align-items: center;
flex: 0 1 60%;
padding: 0 1rem;
border-radius: 0em 0em 1em 1em;
height: 56px;
}
header img {
width: 2.5em;
height: 2.5em;
}
#branding {
position: absolute;
left: 2em;
margin: 0;
margin-left: 0.3em;
font-family: 'Yanone Kaffeesatz', sans-serif;
color: lawngreen;
}
.nav {
display: flex;
flex: 0 1 25%;
justify-content: space-between;
align-items: center;
}
.navitem {
list-style: none;
}
.navitem a {
font-size: 20px;
margin-top: 0;
color: black;
text-decoration: none;
font-family: 'Anton', sans-serif;
}
.navitem a {}
.navitem a:hover {
color: rgba(0, 0, 0, 0.6);
cursor: pointer;
}
/*
************************************************
Header-Styling ENDE
************************************************
*/
main {
display: flex;
flex-direction: column;
align-items: center;
width: 80%;
height: calc(100vh - 56px);
background-color: white;
margin: 0;
margin-right: auto;
margin-left: auto;
overflow-y: auto;
border: 1px solid Maroon;
border-top: 0px;
}
main h2 {
margin: 1em;
font-family: 'Anton', sans-serif;
}
main h4 {
font-size: 2em;
}
/*
************************************************
Hier beginnt das Tabellen-Styling"
************************************************
*/
table {
padding: 1em;
background-color: lightgray;
}
table tr {}
table th {
font-size: 1.5em;
}
table td {
font-weight: 700;
text-align: center;
border-right: 1px solid gray;
border-bottom: 1px solid gray;
padding: 3em;
}
table td:last-child {
border-right: 0px;
padding: 0.3em;
}
td img {
height: 11em;
width: 11em;
}
/*
************************************************
Tabellen-Styling ENDE
************************************************
*/
/*
************************************************
Hier beginnt das Formular Styling
************************************************
*/
form {
padding: 8em;
background-color: slategray;
}
.forms label {
width: 5em;
display:inline-block;
}
<link href="https://fonts.googleapis.com/css?family=Anton|Baloo+Bhaijaan|Gloria+Hallelujah|PT+Sans+Narrow|Righteous|Titillium+Web|Yanone+Kaffeesatz" rel="stylesheet">
<div id="Wrapper">
<header>
<img src="logo.png">
<h1 id="branding">Einfache-Rezepte</h1>
<ul class="nav">
<li class="navitem active">Startseite</li>
<li class="navitem">Rezepte</li>
<li class="navitem">Kontakt</li>
</ul>
</header>
<main>
<form action="mailto:Email" method="post">
<h3>Kontaktiere uns!</h3>
<div class="forms">
<label for="vname">Vorname:</label>
<input type="text" id="vname" name="Vorname">
</div>
<div class="forms">
<label for="nname">Nachname:</label>
<input type="text" id="nname" name="Nachname">
</div>
<div class="forms">
<label for="msg">Ihre Nachricht:</label>
<textarea name="nachricht" cols="40" rows="10"></textarea>
</div>
<input type="submit" value="Absenden">
<input type="reset" value="Zurücksetzen">
</form>
</main>
</div>
You can test it here also.
I'm making a simple calculator page but I'm having a lot of trouble aligning the buttons the way I would like. I have all of my buttons inside of a div which is already the width I want each row of buttons to be. My problem is that no matter how I try to do the margins or the buttons either have extra room on the right side and they don't line up with the right side of the viewport or they are too big and they overflow onto the next line. I'm sure there is a simple solution to this but I'm too much of a beginner to see it. :(
Currently my CSS for the button container and buttons is as follows:
#buttons {
width:525px;
margin-left: 25px;
margin-top: 10px;
}
button {
width: 110px;
height: 110px;
border: 2px solid black;
border-radius: 20px;
margin: 10px 0px 0px 0px;
}
Codepen here.
Try width: 33% on the buttons. It tells the browser to use (roughly) 1/3rd if the available space for each button.
Flex box is worth learning.
Changes are noted with /**/ in the CSS.
Full example, https://codepen.io/anon/pen/LOZEPp
CSS
body {
background-color: #141414;
font-family: 'Rubik', sans-serif;
display: flex; /**/
justify-content: center; /**/
padding: 0; /**/
margin: 0; /**/
}
#calc-main {
background-color: #607466;
width: 550px; /**/
height: 700px; /**/
border: 3px solid black;
border-radius: 20px;
display: flex; /**/
flex-direction: column; /**/
justify-content: space-around; /**/
}
#calc-brand {
flex: 1; /**/
background: yellow;
text-align: center;
padding: 0; /**/
margin: 10px; /**/
}
#calc-viewport {
flex: 1; /**/
margin: 10px; /**/
font-size: 2em;
background-color: #D4D2A5;
padding: 0.25em; /**/
text-align: right;
border: 2px solid black;
border-radius: 20px;
}
#buttons {
margin: 10px; /**/
flex: 16; /**/
background: orange; /**/
display: flex; /**/
flex-direction: column; /**/
align-items: center; /**/
padding: 5px; /**/
}
.button-row { /**/
flex: 1; /* important */
background: yellow;
width: 100%; /**/
margin: 5px; /**/
display: flex; /**/
flex-direction: row; /**/
justify-content: space-between; /**/
}
button {
flex: 1; /* important */
max-width: 110px; /**/
max-height: 110px; /**/
border: 2px solid black;
border-radius: 20px;
margin: 10px; /**/
}
HTML
<body>
<div id='calc-main'>
<h1 id='calc-brand'>JAVASCRIPT CALCULATOR</h1>
<div id='calc-viewport'>
<p id='main-output'>0</p>
<p id='secondary-output'>0</p>
</div>
<div id=buttons>
<div class="button-row">
<button type='button' class='button-danger'>AC</button>
<button type='button' class='button-danger'>CE</button>
<button type='button' class='button-danger'>CE</button>
<button type='button'>÷</button>
</div>
<div class="button-row">
<button type='button' class='button-danger'>AC</button>
<button type='button' class='button-danger'>CE</button>
<button type='button' class='button-danger'>CE</button>
<button type='button'>÷</button>
</div>
<div class="button-row">
<button type='button' class='button-danger'>AC</button>
<button type='button' class='button-danger'>CE</button>
<button type='button' class='button-danger'>CE</button>
<button type='button'>÷</button>
</div>
<div class="button-row">
<button type='button' class='button-danger'>AC</button>
<button type='button' class='button-danger'>CE</button>
<button type='button' class='button-danger'>CE</button>
<button type='button'>÷</button>
</div>
</div>
</div>
</body>
Try This:
.wrapper {
border: 1px solid #000;
text-align: center;
display: inline-block;
background-color: #607466;
}
.result {
margin:10px 20px;
}
input {
height: 20px;
border: 1px solid;
outline: none;
width: 100%;
background: yellow;
}
span {
background: #AAA;
width: 60px;
height: 60px;
display: inline-block;
margin: 0 20px 10px 10px;
line-height: 60px;
float: left;
cursor: pointer;
background: #FFF;
border: 1px solid;
}
span:hover {
background-color: #AAA;
}
.result ~ p {
padding-left: 10px;
clear: both;
}
<div class="wrapper">
<p class="result"><input type="text" name="result"></p>
<p><span>AC</span><span>CE</span><span>/</span><span>*</span></p>
<p><span>7</span><span>8</span><span>9</span><span>-</span></p>
<p><span>4</span><span>5</span><span>6</span><span>+</span></p>
<p><span>1</span><span>2</span><span>3</span><span>=</span></p>
<p><span>0</span><span>.</span><span>Invisible</span></p>
<br style="clear: both">
</div>