Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am trying to shrink upload-container and img-vector when the screen size is reduced but it seems that the upload container is not shrinking in size. I am new to CSS and I am unable to figure out the problem.
Link to my pen
body,
#main-container,
.upload-container,
.drop-zone {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
body,
.upload-container,
.drop-zone {
flex-direction: column;
}
#main-container {
background-color: green;
justify-content:space-around;
width: 100%;
margin: auto;
}
.image-vector {
width: 50vw;
height: 50vh;
flex-shrink: 1;
background: url(https://picsum.photos/200) no-repeat center;
background-size: contain;
}
.upload-container {
background: #17191c;
border-radius: 25px;
flex-shrink: 1;
}
I just added the following code in Responsive Mode. With flex-flow: row wrap; I changed the flex-direction to row and flex-warp to warp break in overflow mode.
#main-container,
.upload-container,
.drop-zone {
flex-flow: row wrap;
}
:root {
--main-bg-color: #212429;
--light-blue: #3a9aed;
--border-color: #3a9aed;
--container-width: 500px;
}
* {
margin: 0px;
padding: 0px;
}
body {
font-family: system-ui;
background: var(--main-bg-color);
height: 98vh;
overflow: hidden;
color: white;
}
body,
#main-container,
.upload-container,
.drop-zone {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
body,
.upload-container,
.drop-zone {
flex-direction: column;
}
.header-container {
position: absolute;
top: 4%;
font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif;
font-size: 55px;
}
#main-container {
background-color: green;
/* justify-content:space-around; */
width: 100%;
margin: auto;
}
.footer-container {
position: absolute;
top: 2%;
left: 80%;
}
.image-vector {
width: 50vw;
height: 50vh;
flex-shrink: 1;
background: url(https://picsum.photos/200) no-repeat center;
background-size: contain;
}
.upload-container {
background: #17191c;
border-radius: 25px;
flex-shrink: 1;
}
.drop-zone {
width: var(--container-width);
min-height: 200px;
border: 2px dashed var(--border-color);
border-radius: 10px;
margin: 30px;
transition: 0.2s all ease-in;
}
/* will be added when user drags */
.drop-zone.dragged {
background: var(--main-bg-color);
border-color: #0288d1;
}
.drop-zone input {
display: none;
}
.icon-container {
position: relative;
width: 75px;
height: 100px;
}
.icon-container img {
width: 75px;
position: absolute;
transition: transform 0.25s ease-in-out;
transform-origin: bottom;
}
.icon-container .center {
z-index: 10;
}
.icon-container .right,
.icon-container .left {
filter: grayscale(0.5);
transform: scale(0.9);
}
.dragged .center {
transform: translateY(-5px);
}
.dragged .right {
transform: rotate(10deg) scale(0.9) translateX(20px);
}
.dragged .left {
transform: rotate(-10deg) scale(0.9) translateX(-20px);
}
.title {
font-size: large;
}
#browseBtn {
color: #2196f3;
cursor: pointer;
}
/* uploading progress styles */
.progress-container {
border: 2px solid var(--main-bg-color);
width: var(--container-width);
height: 70px;
border-radius: 10px;
margin-bottom: 25px;
position: relative;
display: none;
}
.progress-container .inner-container {
margin: 10px 15px;
z-index: 2;
position: absolute;
width: calc(100% - 30px);
}
.progress-container .percent-container {
font-size: 14px;
margin: 5px;
opacity: 0.7;
}
.progress-container .bg-progress {
position: absolute;
background: var(--main-bg-color);
width: 100%;
height: 100%;
z-index: 1;
transition: transform 250ms linear;
transform: scaleX(0);
transform-origin: left;
}
.progress-container .progress-bar {
width: 100%;
height: 3px;
border-radius: 2px;
background: #03a9f4;
transition: transform 200ms linear;
transform: scaleX(0);
transform-origin: left;
}
/* sharing container style */
.sharing-container {
margin-bottom: 25px;
width: var(--container-width);
border-radius: 10px;
display: none;
}
.sharing-container p {
text-align: center;
}
.sharing-container .expire {
font-size: 16px;
opacity: 0.7;
margin-top: 0;
}
.sharing-container .input-container {
display: flex;
position: relative;
width: 100%;
margin-bottom: 20px;
}
.sharing-container .input-container input {
width: 100%;
border-radius: 3px;
padding: 10px 15px;
font-size: 20px;
border: 2px dashed var(--border-color);
border-radius: 6px;
background: #17191c;
color: #ffffff;
}
.sharing-container img {
height: 22px;
width: 30px;
position: absolute;
right: 7px;
top: 12px;
cursor: pointer;
background: #17191c;
color: #ffffff;
}
.email-container form {
border: 2px solid var(--border-color);
width: 100%;
padding: 15px;
box-sizing: border-box;
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
.email-container,
.send-btn-container {
display: flex;
flex-direction: column;
align-items: center;
}
.email-container label {
margin: 5px;
font-size: 18px;
}
.email-container input {
border: none;
border-bottom: 2px solid var(--border-color);
height: 19px;
font-size: 18px;
text-align: center;
}
.email-container input:focus {
outline: none;
}
.email-container .filed {
margin-bottom: 5px;
display: flex;
justify-content: space-between;
width: 400px;
}
.send-btn-container button {
font-size: 18px;
padding: 8px 40px;
margin-top: 15px;
background: #3a9aed;
border: none;
border-radius: 5px;
color: #ffffff;
cursor: pointer;
}
.toast {
position: absolute;
bottom: 10px;
right: 50%;
transform: translate(50%, 60px);
padding: 10px 20px;
background: var(--light-blue);
color: #fff;
border-radius: 5px;
font-size: 18px;
box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, 0.1),
0px 4px 6px -2px rgba(0, 0, 0, 0.05);
transition: transform ease-in-out 0.2s;
}
.image-vector {
background: url("https://picsum.photos/200") no-repeat center;
background-size: contain;
height: 50vh;
width: 50vw;
}
.show.toast {
transform: translate(50%, 0);
}
#media screen and (max-width: 900px) {
:root {
--container-width: 320px;
}
body,
#main-container,
.upload-container,
.drop-zone {
flex-flow: row wrap;
}
.email-container .filed {
flex-direction: column;
}
.email-container .filed {
width: 300px;
}
}
<div class="header-container">EZ Sharing</div>
<main id='main-container'>
<section class="upload-container">
<form action="">
<div class="drop-zone">
<div class="icon-container">
<img src="https://picsum.photos/200" draggable="false" class="center" alt="File Icon" />
<img src="https://picsum.photos/200" draggable="false" class="left" alt="File Icon" />
<img src="https://picsum.photos/200" draggable="false" class="right" alt="File Icon" />
</div>
<input type="file" id="fileInput" />
<div class="title">
Drop your Files here or,
<span id="browseBtn">Browse</span>
</div>
</div>
</form>
<div class="progress-container">
<div class="bg-progress"></div>
<div class="inner-container">
<div class="status">Uploading...</div>
<div class="percent-container">
<span class="percentage" id="progressPercent">0 %</span>
</div>
<div class="progress-bar"></div>
</div>
</div>
<div class="sharing-container">
<p class="expire">Link expires in 24 hrs</p>
<div class="input-container">
<input type="text" id="fileURL" readonly />
<img src="./copy-icon.svg" id="copyURLBtn" alt="copy to clipboard icon" />
</div>
<p class="email-info">Or Send via Email</p>
<div class="email-container">
<form id="emailForm">
<div class="filed">
<label for="fromEmail">Your email</label>
<input type="email" autocomplete="email" required name="from-email" id="fromEmail" />
</div>
<div class="filed">
<label for="toEmail">Receiver's email</label>
<input type="email" required autocomplete="receiver" name="to-email" id="toEmail" />
</div>
<div class="send-btn-container">
<button type="submit">Send</button>
</div>
</form>
</div>
</div>
</section>
<div class="image-vector"></div>
</main>
<div class="toast">Sample message</div>
<div class="footer-container">
<a href="" target="_blank">
<img border="0" alt="Facebook" src="./github-logo.svg" width="50" height="50" />
</a>
<a href="/" target="_blank">
<img border="0" alt="Facebook" src="./linkedin.svg" width="50" height="50" />
</a>
<a href="">
<img border="0" alt="Facebook" src="./facebook.svg" width="50" height="50" />
</a>
</div>
Related
When I resize the page the searchbox starts resizing after the padding of the parent if zero. I want to resize the div with class-"searchbox", with resizing the page not after the parent's padding is off. Here is the code I'll be glad if you correct me anywhere.
.site-wrapper {
max-width: 86.5rem;
min-height: 28rem;
padding: 0 4.3rem;
margin: 0 auto;
overflow: hidden;
}
.navbar {
display: flex;
justify-content: end;
padding-top: 2.7rem;
}
#hamburger-button {
position: relative;
width: 32px;
height: 32px;
border-radius: 4px;
cursor: pointer;
}
#hamburger-button:hover {
background-color: #0000001f;
}
#hamburger {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: none;
background-color: transparent;
background-image: url(/assets/menuicon.svg);
background-repeat: no-repeat;
background-size: contain;
padding: 9.2px;
margin: 0 auto;
cursor: pointer;
}
.header-content {
margin: 0 auto;
}
.header-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.header-content-logo {
margin-top: 5rem;
margin-bottom: 2.3rem;
}
.header-content-logo svg {
width: 12.6rem;
}
.searchbox {
display: flex;
align-items: center;
border-radius: 6px;
width: 100%;
max-width: 38.7rem;
height: 2.7rem;
background-color: #fff;
box-shadow: 0px 2px 6px 1px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.searchbox:hover {
box-shadow: 0px 6px 20px 6px rgba(0, 0, 0, 0.1);
}
.searchbox input {
width: 92%;
border: none;
background-color: transparent;
font-size: 11.8pt;
font-family: inherit;
padding-left: 1rem;
}
.searchbox input:focus {
outline: none;
}
<div class="site-wrapper">
<div class="navbar">
<div id="hamburger-button">
<button id="hamburger"></button>
</div>
</div>
<div class="header-content">
<div class="header-content-logo">
<svg>
</div>
<div class="searchbox">
<input type="text" placeholder="Search without being tracked">
</div>
</div>
</div>
I have tried putting margin and even making another div before it and putting padding but seems that it didn't make it work. I am out of options.
This is my goal:
Some circular buttons that have an hover state: on mouseover, a black container with some text (with different length) should appear growing from left to right.
I didn't know how to do that. My doubts are about how to set the two different width because it should be from 0 to auto but if it's 0, then mouseover can't work.
Here is my sample code:
.container {
background-color: lightgray;
width: 60px;
height: 100px;
padding-top: 20px;
padding-left: 20px;
}
.item-container {
position: relative;
overflow: visible;
}
.item {
border-radius: 100%;
padding: 8px;
width: 10px;
height: 10px;
cursor: pointer;
background-color: white;
border: 1px solid black;
}
.circle {
width: 10px;
height: 10px;
border-radius: 100%;
background-color: tomato;
}
.hovered-elem {
position: absolute;
top: 0px;
left: 0px;
width: auto;
height: 100%;
white-space: nowrap;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 30px;
padding-right: 15px
}
.hovered-elem-text-container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
white-space: nowrap;
padding-left: 40px;
color: white;
}
<div class="container">
<div class="item-container">
<div class="item">
<div class="circle"/>
</div>
<div class="hovered-elem">
<div class="hovered-elem-text-container">
Lilly Martin
</div>
</div>
</div>
<div>
Here's a start. I think it's all pretty self-explanatory. The max-width on the text elements is arbitrary--set it to something that will fit all possible names.
I simplified the markup a bit. You could take it further by making the inner circles pseudo-elements if you like.
* {
box-sizing: border-box;
}
.container {
display: inline-block;
background-color: #ddd;
width: 62px;
padding-left: 10px;
}
.item {
display: inline-flex;
align-items: center;
border-radius: 32px;
padding: 8px;
margin: 16px 0;
cursor: pointer;
border: 1px solid black;
background: white;
font-family: Verdana, Arial, sans-serif;
transition: all .5s;
}
.circle {
width: 24px;
height: 24px;
border-radius: 100%;
background-color: #CD4025;
}
.item:nth-child(2) .circle {
background-color: #0097A7;
}
.item:nth-child(3) .circle {
background-color: #FFAC40;
}
.text {
color: #fff;
max-width: 0;
overflow: hidden;
white-space: nowrap;
transition: all 1s;
}
.item:hover {
background: #000;
transition: all .5s;
}
.item:hover .text {
max-width: 200px;
margin: 0 16px;
transition: all 1s;
}
<div class="container">
<div class="item">
<div class="circle"></div>
<div class="text">Lilly Martin</div>
</div>
<div class="item">
<div class="circle"></div>
<div class="text">Philip McDaniel</div>
</div>
<div class="item">
<div class="circle"></div>
<div class="text">Tom Bombadil</div>
</div>
</div>
You can do this CSS transitions and altering the scale of the div while the circle item is hovered. Take a look what I did here:
.container {
background-color: lightgray;
width: 60px;
height: 100px;
padding-top: 20px;
padding-left: 20px;
}
.item-container {
position: relative;
overflow: visible;
}
.item {
border-radius: 100%;
padding: 8px;
width: 10px;
height: 10px;
cursor: pointer;
background-color: white;
border: 1px solid black;
}
.circle {
width: 10px;
height: 10px;
border-radius: 100%;
background-color: tomato;
}
.hovered-elem {
position: absolute;
top: 0px;
left: 0px;
width: auto;
height: 100%;
white-space: nowrap;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 30px;
padding-right: 15px;
scale: 0;
transform-origin: left;
transition: all 200ms ease-in-out;
}
.hovered-elem-text-container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
white-space: nowrap;
padding-left: 40px;
color: white;
}
.item:hover .hovered-elem{
scale: 1;
}
<div class="container">
<div class="item-container">
<div class="item">
<div class="circle"/>
</div>
<div class="hovered-elem">
<div class="hovered-elem-text-container">
Lilly Martin
</div>
</div>
</div>
<div>
I have searched all over stack overflow but I am unable to find any clue and I am struck here. I used flex container and child items in my code to some extent but I couldn't move beyond that. Thing is when we hover a child item, a new child item need to be created as shown in the expected result. Should we need to use pseudo element or any other flex properties to achieve this. Thanks much in advance.
My code:
https://jsfiddle.net/k2qr398u/1/
My result
https://imgur.com/kRHNHuu
Expected result:
https://imgur.com/2B6CkYF
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
/* position: relative; */
}
.col p {
font-size: 16px;
font-weight: bold;
}
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
<div class="col col-2">
<p class="my-name">Sri</p>
</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</body>
P.S: Sorry if this question sounds very silly or dumb, I am a beginner trying to learn web dev skillsets.
I have created something similar to your expected result. Please run the code snippet for the result.
UPDATE: To include the hover off transition.
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
position: relative;
}
.col p {
font-size: 16px;
font-weight: bold;
}
/*
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
*/
.col-1,
.col-2-1,
.col-2-2,
.col-3 {
position: absolute;
left: 0;
top: 0;
transition: 1s;
}
.wrapper {
position: relative;
}
.wrapper:hover .col-1 {
transition: 1s;
left: -200px;
}
.wrapper:hover .col-2-1 {
transition: 1s;
top: -170px;
}
.wrapper:hover .col-2-2 {
transition: 1s;
top: 170px;
}
.wrapper:hover .col-3 {
transition: 1s;
left: 200px;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-2-1">
<p class="my-name">Sri</p>
</div>
<div class="col col-2-2">
<p class="my-name">Pratham</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</div>
</body>
The idea is:
Overlay some content over main content.
On hover reveal it :)
.card {
width: 150px;
height: 80px;
border: 1px solid #999;
background: #ccc;
border-radius: 8px;
position: relative;
margin: 20% auto;
}
.card:hover > .o-top {
top: -80px;
background: #f00;
}
.card:hover > .o-bottom {
bottom: -80px;
}
.o-top {
top: 0;
transition: top 1.5s, background 2s;
}
.o-bottom {
bottom: 0;
transition: bottom 1.5s, background 2s;
}
.card-overlay {
position: absolute;
height: 100%;
width: 100%;
background: #333;
pointer-events: none;
color: #fff;
}
<div class="card">
<div class="card-overlay o-top">TOP OVERLAY</div>
<div class="card-overlay o-bottom">BOTTOM OVERLAY</div>
<H3>INTERNAL CONTENT</H3>
</div>
I'm trying to make my page's nav menu responsive. Currently, icons don't fit on the screen as the height is decreased. Ideally what I'm wanting is a responsive design where all of the elements scale with the page height (ie, icons and text shrinks to fit).
So far, I can only get the design to work with hard-coded values as below. This requires multiple breakpoints which I'm trying to avoid as getting everything to fit just right with hard coded values is proving too lengthy a process.
https://jsfiddle.net/froggomad/392qje0o/
.topnav {
position: fixed;
width: 100%;
width: 100vw;
background-color: transparent;
}
.topnav #myLinks {
display: block;
position: fixed;
top: 15%;
height: 85vh;
width: 400px;
margin-left: 80%;
margin-right: 5%;
background-color: transparent;
border-radius: 10px;
bottom: 5%;
}
.menu-link {
padding-top: 0.5em;
}
.menu-card {
display: block;
text-align: center;
opacity: 100%;
padding: 0;
margin: 0;
margin-bottom: 18%;
}
.menu-card:hover {
background-color: transparent;
opacity: 100%;
transition: all 0.8s;
}
/*Transforms .card-text when hovering on .menu-card*/
.menu-card:hover .card-text {
opacity: 100;
max-width: 66%;
/*this is the attribute being animated in .card-text*/
width: 38%;
/*sets actual width*/
background-color: rgba(148, 181, 201, 0.9);
border-width: 8px;
}
.menu-icon {
display: inline;
text-align: center;
margin-left: -265px;
margin-right: 0;
padding-left: 0;
padding-bottom: 0;
max-width: 20%;
vertical-align: middle;
background-color: rgba(148, 181, 201, 0.9);
border-radius: 90px;
padding: 8px;
}
.card-text {
max-width: 0%;
opacity: 0;
color: #5DCA31;
background-color: transparent;
text-shadow: 2px 2px black;
float: left;
vertical-align: middle;
margin: 0;
margin-right: 22%;
padding: 0.5em;
padding-right: 140px;
padding-left: 2%;
padding-top: 24px;
padding-bottom: 35px;
border-color: rgba(148, 181, 201, 0.9);
border-width: 0px;
border-style: solid;
border-radius: 90px;
transition: background-color 0.8s, border-width 0.8s, max-width 0.8s;
}
#home {
/*Text*/
font-size: 1.5em;
margin-top: 3%;
}
.home {
/*Icon*/
margin-top: 3%;
}
#strategy {
font-size: 1.25em;
}
#security {
font-size: 1.5em;
}
#pledge {
font-size: 1.5em;
}
<div class="topnav">
<div class="top-bar">
<a href="#" id="site-title">
Site Title
</a>
</div>
<!-- Navigation links (hidden by default) -->
<div id="myLinks" class="menu-link">
<div class="menu-card">
<a href="#">
<img class="menu-icon home" src="https://www.shareicon.net/data/128x128/2015/09/22/104866_home_512x512.png">
<p class="card-text" id="home">Home</p>
</a>
</div>
<div class="menu-card">
<a href="#">
<img class="menu-icon" src="https://www.shareicon.net/data/128x128/2015/09/21/104860_find_512x512.png">
<p class="card-text" id="strategy">Current Strategy</p>
</a>
</div>
<div class="menu-card">
<a href="#">
<img class="menu-icon" src="https://www.shareicon.net/data/128x128/2015/09/22/104877_locked_512x512.png">
<p class="card-text" id="security">Security</p>
</a>
</div>
<div class="menu-card">
<a href="#">
<img class="menu-icon" src="https://www.shareicon.net/data/128x128/2015/09/22/104870_users_512x512.png">
<p class="card-text" id="pledge">Pledge!</p>
</a>
</div>
<!--End Navigation links-->
</div>
</div>
Here's a working version using flexbox and position absolute.
https://jsfiddle.net/my6nwu0e/
.top-bar {
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
}
.topnav {
position: fixed;
width: 100vw;
}
.topnav #myLinks {
display: flex;
flex-direction: column;
position: fixed;
width: 300px;
top: 10%;
right: 0;
height: 85vh;
max-height: 85%;
border-radius: 10px;
}
.menu-link {
padding-top: 0.5em;
}
.menu-card {
display: flex;
justify-content: center;
flex: 1 1 25%;
}
.menu-card a {
position: relative;
width: 100%;
}
.menu-icon {
position: absolute;
z-index: 1;
right: 20%;
max-height: 65%;
border-radius: 50%;
background-color: rgba(148, 181, 201, 0.9);
transition: all 0.8s;
}
.card-text {
display: flex;
align-items: center;
width: 0;
top: 6%;
height: 100%;
max-height: 0;
text-align: left;
font-size: 100%;
opacity: 0;
color: #5DCA31;
background-color: transparent;
text-shadow: 2px 2px black;
margin: 0;
border-color: rgba(148, 181, 201, 0.9);
border-style: solid;
border-radius: 90px;
transition: all 0.8s;
}
.menu-card:hover {
background-color: transparent;
opacity: 1;
transition: all 0.8s;
}
.menu-card:hover .menu-icon {
right: 0;
}
.menu-card:hover .card-text {
opacity: 1;
padding-left: 10%;
max-height: 65%;
width: 100%;
border-width: 8px;
box-sizing: border-box;
background-color: rgba(148, 181, 201, 0.9);
}
#media screen and (max-height: 700px) {
.topnav #myLinks {
width: 200px;
}
}
You were using too many margin properties, and seemed like there were a lot of unnecessary/redundant styles, although maybe they depended on the other styles in the page that you did not post. You will have to change the the width of #myLinks using media query, but other than that I think this is a pretty responsive solution. Also consider using box-sizing: border-box as a global style.
I am almost finish with building the skeleton of my simon game clone and the only left I want to do is set the container (which holds the game itself) to have a max height of 605px.
I was able to accomplish its width max when it reaches a certain threshold in the viewport but I am having hard time applying the same behavior but horizontally instead.
Any inputs will be greatly appreciated.
I've attached my code in CodePen as well:
http://codepen.io/neotriz/pen/RRxOJb
body {
background: skyblue;
font-family: 'Righteous', cursive;
box-sizing: border-box; }
.container {
width: 100%;
display: flex;
flex-wrap: wrap; }
.game {
display: flex;
flex-wrap: wrap;
width: 100%;
height: 70vh;
margin-top: 10px; }
.button {
position: relative;
display: block;
height: 50%;
width: 50%;
margin-bottom: 1px; }
#green {
background: #39d565;
border-top-left-radius: 25%;
box-shadow: 0 6px 0 #0d934b;
bottom: 6px;
transition: all 0.1s linear; }
#green:active {
bottom: 0px;
box-shadow: 0px 0px 0px #0d934b; }
#red {
background: #d23a51;
border-top-right-radius: 25%;
box-shadow: 0 6px 0 #711515;
bottom: 6px;
transition: all 0.1s linear; }
#red:active {
bottom: 0px;
box-shadow: 0px 0px 0px #711515; }
#blue {
background: #09f;
border-bottom-left-radius: 25%;
box-shadow: 0 6px 0 #06c;
bottom: 6px;
transition: all 0.1s linear; }
#blue:active {
bottom: 0px;
box-shadow: 0px 0px 0px #06c; }
#yellow {
background: #FD9A01;
border-bottom-right-radius: 25%;
box-shadow: 0 6px 0 #916828;
bottom: 6px;
transition: all 0.1s linear; }
#yellow:active {
bottom: 0px;
box-shadow: 0px 0px 0px #916828; }
.score {
width: 100%;
height: 10vh;
text-align: center;
color: #FFF;
text-shadow: 1px 3px 2px black;
margin-bottom: 5px; }
.control-panel {
text-align: center;
width: 100%;
display: flex;
flex-wrap: wrap;
position: relative;
height: 15vh;
align-items: center;
justify-content: center;
background: #aaaaaa;
border-radius: 10px; }
.control-panel #on-off-btn {
width: 33.3333%; }
.control-panel #level {
width: 33.3333%; }
.control-panel #start {
width: 33.3333%; }
.control-panel p {
margin: 8px 0px 0px 0px; }
.cmn-toggle {
position: absolute;
margin-left: -9999px;
visibility: hidden; }
.cmn-toggle + label {
display: block;
position: relative;
cursor: pointer;
outline: none;
user-select: none; }
input.cmn-toggle-round + label {
padding: 2px;
max-width: 90%;
height: 35px;
background-color: #dddddd;
border-radius: 60px;
margin-top: 9px;
margin-left: 5px; }
input.cmn-toggle-round + label:before,
input.cmn-toggle-round + label:after {
display: block;
position: absolute;
top: 1px;
left: 1px;
bottom: 1px;
content: ""; }
input.cmn-toggle-round + label:before {
right: 1px;
background-color: white;
border-radius: 60px;
transition: background 0.4s; }
input.cmn-toggle-round + label:after {
width: 38px;
background-color: #fff;
border-radius: 100%;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
transition: margin-left 0.4s; }
input.cmn-toggle-round:checked + label:before {
background-color: #8ce196; }
input.cmn-toggle-round:checked + label:after {
margin-left: 58%; }
.btn-round {
width: 50%;
height: 50px;
background: #ed2914;
border-radius: 100%;
outline: none;
box-shadow: 0 6px 0 #711515;
bottom: 6px;
transition: all 0.1s linear; }
.btn-round:active {
bottom: 0px;
box-shadow: 0px 0px 0px #711515; }
#media screen and (max-width: 311px) {
input.cmn-toggle-round:checked + label:after {
margin-left: 45%; } }
#media screen and (min-width: 426px) {
.container {
width: 426px;
margin-left: auto;
margin-right: auto; }
input.cmn-toggle-round:checked + label:after {
margin-left: 66%; } }
#media screen and (min-height: 605px) {
.container {
height: 605px; } }
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simon Game FCC</title>
</head>
<body>
<div class="container">
<div class="game">
<div id="green" class="button"></div>
<div id="red" class="button"></div>
<div id="blue" class="button"></div>
<div id="yellow" class="button"></div>
</div>
<div class="score">
<h2>Score: 0 </h2>
</div>
<div class="control-panel">
<div id="on-off-btn">
<input id="on-off-slider"type="checkbox" class="cmn-toggle cmn-toggle-round">
<label for="on-off-slider"></label>
<p>Off/On</p>
</div>
<div id="level">
<input id="level-slider"type="checkbox" class="cmn-toggle cmn-toggle-round">
<label for="level-slider"></label>
<p>Level</p>
</div>
<div id="start">
<button class="btn-round"></button>
<p>(re)Start</p>
</div>
</div>
</div>
</body>
</html>
I think mixing vh heights and flex disposition is part of the problem because it makes the code a bit tricky to adjust. So I would suggest to remove all vh heights that are inside the container and replace them with a flex vertical positionning.
Here is the sccs I get (only the changed rules are here) :
.container {
width: 100%;
display: flex;
flex-wrap: wrap;
height: 100vh;
flex-direction: column;
justify-content: center; }
.game {
display: flex;
flex-wrap: wrap;
width: 100%;
margin-top: 10px;
flex: 1 1 auto; }
.score {
width: 100%;
text-align: center;
color: #FFF;
text-shadow: 1px 3px 2px black;
margin-bottom: 5px;
flex: 0 0 auto; }
.control-panel {
text-align: center;
width: 100%;
display: flex;
flex-wrap: wrap;
position: relative;
align-items: center;
justify-content: center;
background: #aaaaaa;
border-radius: 10px;
flex: 0 0 auto; }