I have a 1x4 grid that looks like this.
The problem is that when the screen is widened, the buttons sometimes get cut off, and when they don't they're too horizontally stretched.
I would like to adjust the 1x4 grid to become a 2x2 when there's not enough vertical space.
I know this is possible with flex containers, but I'm failing in my attempts to figure out how.
This is my codepen:
https://codepen.io/TheNomadicAspie/pen/ZEKYwWJ
And this is the relevant code:
.multiple-choice {
}
.answer-1 {
grid-rows: 1/2;
display: grid;
grid-template-columns: 20% 80%;
height: 98%;
}
.answer-2 {
grid-rows: 2/3;
display: grid;
grid-template-columns: 20% 80%;
height: 98%;
}
.answer-3 {
grid-rows: 3/4;
display: grid;
grid-template-columns: 20% 80%;
height: 99%;
}
.answer-4 {
grid-rows: 4/5;
display: grid;
grid-template-columns: 20% 80%;
height: 99%;
}
.checkbox {
grid-columns: 1/2;
max-height: 90%;
background-image: url('checkbox_unchecked.png');
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
.button-container {
grid-columns: 2/3;
height: %;
padding-left: 5%;
}
.button-container button {
width: 100%;
}
.button {
display: inline-block;
height: 100%;
text-decoration: none;
background: black; /*Button Color*/
color: #f5f5f5;
border-bottom: solid 4px #f5f5f5;
border-radius: 3px;
font-family: hack;
font-size: 1.5rem;
font-size: clamp(1rem, 3vw, 2rem);
padding-left: 5%;
padding-right: 5%;
padding-top: 2%;
padding-bottom: 2%;
}
.btn:active {
/*on Click*/
-ms-transform: translateY(4px);
-webkit-transform: translateY(4px);
transform: translateY(4px); /*Move down*/
border-color: black; /*disappears*/
}
Related
I am Having a lof of problems trying to create a message card for my app. Basically I want to the content of the message div to be align with the name of the person,like this app .I already Tried to change the display to flex wrap,but still not the same, And I am looking if it's possible to re-create what this person did on the image here
Right now mine is this:
::-webkit-scrollbar {
width: 3px;
height: 3px;
}
::-webkit-scrollbar-button {
width: 0px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #fc0303;
border: 100px none #ffffff;
border-radius: 7px;
}
::-webkit-scrollbar-thumb:hover {
background: #fc0303;
}
::-webkit-scrollbar-thumb:active {
background: #000000;
}
::-webkit-scrollbar-track {
background: #191919;
border: 100px none #ffffff;
border-radius: 100px;
}
::-webkit-scrollbar-track:hover {
background: #191919;
}
::-webkit-scrollbar-track:active {
background: #333333;
}
::-webkit-scrollbar-corner {
background: transparent;
}
#menu_icon {
width:40px;
height:40px;
border-radius:50%;
transition: transform .9s;
float:right
}
#menu_icon:hover {
cursor:pointer;
-ms-transform: scale(1.1); /* IE 9 */
-webkit-transform: scale(1.1); /* Safari 3-8 */
transform: scale(1.1);
}
.chat_box{
background-color:#191919;
overflow: scroll;
overflow-x: hidden;
border: 2px black dashed;
width:100%;
height:100%;
border-radius:3px;
padding:10px;
}
.chat_box_message_content{
display:block;
}
.msg-txt {
display: flex;
flex-flow: wrap column;
width: 80%;
}
.chat_box_message_content p{
color:white;
}
.chat_box_message_content img {
width:35px;
height:35px;
border-radius:50%;
}
body {
background: #eef0f1;
color: black;
font-family: "Roboto", sans-serif;
overflow-x: hidden;
}
<div id="chat_box" class="chat_box">
<img onclick="showMenu()" id="menu_icon" src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg">
<p style="color:white;font-size:13px;font-style: oblique;margin-top:50px">Usuário Conectado ao servidor!</p>
<div class="chat_box_message_content">
<img src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg">
<span style="color:#9b72da" class="chat_box_message_content_icon">o</span>
<p class="chat_box_message_content_msg">
AAAAAAAAA
</p>
</div>
<div class="chat_box_message_content">
<img src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg">
<span style="color:#da729f" class="chat_box_message_content_icon">Maria</span>
<p class="chat_box_message_content_msg">
teste
</p>
</div>
</div>
Can U guys help me with it?
Add display: inline to your ".chat_box_message_content p" CSS class to be like this:
.chat_box_message_content p {
color:white;
display: inline;
}
You can try to make the card div have display: grid and then set the content's positions inside the grid. Something like that:
::-webkit-scrollbar {
width: 3px;
height: 3px;
}
::-webkit-scrollbar-button {
width: 0px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #fc0303;
border: 100px none #ffffff;
border-radius: 7px;
}
::-webkit-scrollbar-thumb:hover {
background: #fc0303;
}
::-webkit-scrollbar-thumb:active {
background: #000000;
}
::-webkit-scrollbar-track {
background: #191919;
border: 100px none #ffffff;
border-radius: 100px;
}
::-webkit-scrollbar-track:hover {
background: #191919;
}
::-webkit-scrollbar-track:active {
background: #333333;
}
::-webkit-scrollbar-corner {
background: transparent;
}
#menu_icon {
width: 40px;
height: 40px;
border-radius: 50%;
transition: transform .9s;
float: right
}
#menu_icon:hover {
cursor: pointer;
-ms-transform: scale(1.1);
/* IE 9 */
-webkit-transform: scale(1.1);
/* Safari 3-8 */
transform: scale(1.1);
}
.chat_box {
background-color: #191919;
overflow: scroll;
overflow-x: hidden;
border: 2px black dashed;
width: 100%;
height: 100%;
border-radius: 3px;
padding: 10px;
}
.chat_box_message_content {
display: grid;
grid-template-columns: 50px 5fr;
grid-template-rows: 20px 30px;
margin: 2em 0;
grid-column-gap: 15px;
}
.msg-txt {
display: flex;
flex-flow: wrap column;
width: 80%;
}
.chat_box_message_content span {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 1;
}
.chat_box_message_content p {
color: white;
grid-column-start: 2;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
padding: 5px 0;
}
.chat_box_message_content img {
width: 100%;
max-width: 45px;
height: auto;
border-radius: 50%;
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
}
body {
background: #eef0f1;
color: black;
font-family: "Roboto", sans-serif;
overflow-x: hidden;
}
I am having issues with my Wordpress website. Whenever I use the following CSS. my website crashes on the mobile version (but not on the computer) "A problem repeatedly occurred on https://..."
.about-text .iwt-text {
font-size: 16px;
line-height: 1.38;
max-width: 245px;
}
#js {
display: none !important;
}
.about-text .iwt-icon img {
width: 19px;
height: 23px;
margin-top: 3px;
}
.about-heading {
text-transform: uppercase;
margin: 0 0 5% 0% !important;
}
.header {
padding-top:40px;
padding-bottom:30px;
}
.header h1 {
color:#000640;
}
/** SPEAKERS **/
#speaker h2 {
font-size: 36px;
font-weight: normal;
line-height: 1.11;
margin-bottom: .5em;
letter-spacing: 2px;
color: #000640;
}
#media (min-width: 1000px) {
#speaker h2 {
font-size: 120px;
font-weight: bold;
line-height: .67;
position: absolute;
bottom: 4px;
margin: 0;
margin-left: -7rem;
letter-spacing: 7.54px;
opacity: .44;
color: #dee0f1 !important;
}
#speaker h3, #speaker h1, #speaker p {
color: #fff !important;
}
#speaker h3 {
margin-top: 3rem;
}
#speaker p {
margin-bottom: 7rem !important;
}
#speaker .row-bg-wrap::after {
position: absolute;
top: 0;
left: -35vw;
display: block;
width: 123vw;
height: 100%;
content: '';
background: url(https://albertablockchain.com/wp-content/uploads/2020/01/group-1219.svg) center / cover no-repeat;
}
#speaker {
margin-top: 4rem;
}
#speaker img {
margin-top: -4rem;
}
}
#speaker h3 {
margin-bottom: 20px;
}
#speaker h1 {
font-size: 34px;
font-weight: bold;
margin-bottom: 35px;
letter-spacing: 1.5px;
}
#media (min-width: 1000px) {
#speaker p {
max-width: 414px;
margin-bottom: 15%;
}
}
div.speaker-line img {
width: 100%;
}
div.single-speaker {
display: flex;
flex-flow: column;
justify-content: space-between;
height: 100%;
padding: 1.5rem;
}
div.single-speaker div.top {
display: flex;
align-items: flex-start;
}
div.single-speaker div.top img {
width: 82px !important;
}
#media (max-width: 1000px) {
div.single-speaker div.top {
flex-flow: column;
}
}
div.single-speaker img {
width: auto;
margin-right: 1.5rem;
}
div.single-speaker img + div > p {
padding: 0;
}
div.single-speaker p {
line-height: 1.57;
color: #333;
}
div.single-speaker a {
font-size: 12px;
line-height: 1.83;
color: #3c4bd8;
}
div.single-speaker h2 {
font-size: 16px;
line-height: 1.56;
margin-top: 1em;
letter-spacing: 1.07px;
color: #142098;
}
div.popup-trigger {
cursor: pointer;
transition: box-shadow .3s ease-in-out;
box-shadow: 0 25px 81px -37px rgba(24, 27, 61, .27) !important;
}
div.popup-trigger:hover {
box-shadow: 0 25px 81px -37px rgba(24, 27, 61, .7) !important;
}
div.popup-trigger div.vc_column-inner > div.wpb_wrapper {
display: grid;
grid-template-rows: auto 1fr;
height: 100%;
}
div.popup-trigger div.wpb_raw_code > div.wpb_wrapper {
height: 100%;
}
/** SPEAKERS GRID */
.speakers {
display: grid;
gap: 1.5rem;
}
.speakers .item {
display: grid;
grid-template-rows: auto 1fr;
transition: box-shadow .3s ease-in-out;
border-radius: 4px;
background: #fff;
box-shadow: 0 25px 81px -37px rgba(24, 27, 61, .27);
}
.speakers .item.trigger {
cursor: pointer;
}
.speakers .item:hover {
box-shadow: 0 25px 81px -37px rgba(24, 27, 61, .7);
}
.speakers .item .img img {
width: 100%;
margin: 0;
}
#media (min-width: 1000px) {
.speakers {
grid-template-columns: repeat(3, 1fr);
}
}
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.speakers {
display: flex;
flex-wrap: wrap;
}
.speakers .item {
display: flex;
flex-flow: column;
flex-basis: 30%;
}
}
.speaker-modal {
position: fixed;
z-index: 9999;
top: 0;
left: 0;
display: flex;
width: 100vw;
height: 100vh;
transform: scale(0);
pointer-events: none;
background: #fff;
}
.speaker-modal.active {
transform: scale(1);
pointer-events: all;
}
.speaker-modal .modal-image img {
width: 100% !important;
height: 100% !important;
object-fit: cover;
object-position: top;
}
.speaker-modal div.modal-left {
overflow-y: auto;
max-height: 100%;
padding: 6rem;
}
#media (min-width: 1000px) {
.speaker-modal > div {
flex-basis: 50%;
}
.speaker-modal div.modal-left {
display: flex;
align-items: flex-start;
flex-flow: column;
justify-content: center;
}
}
#media (max-width: 1000px) {
.speaker-modal div.modal-image {
max-height: 50vh;
}
}
.speaker-modal div.modal-left::-webkit-scrollbar {
width: 0;
}
.speaker-modal .js-close-modal {
position: absolute;
top: 3rem;
right: 3rem;
display: flex;
align-items: center;
justify-content: center;
width: 51px;
height: 51px;
content: '';
cursor: pointer;
border-radius: 100%;
background: #fff;
}
.speaker-modal .js-close-modal::after {
position: absolute;
display: block;
width: 25px;
height: 25px;
content: '';
background: url(https://albertablockchain.com/wp-content/plugins/VC_Modal_Popup/img/cross.png) no-repeat center center;
filter: brightness(0);
}
.speaker-modal div.modal-left img {
width: 164px !important;
object-fit: contain;
}
.speaker-modal div.modal-left h2 {
font-size: 20px;
line-height: 1.25;
margin-bottom: .5em;
letter-spacing: 1px;
color: #142098;
}
.speaker-modal div.modal-left a {
font-size: 12px;
line-height: 1.83;
color: #3c4bd8;
}
.speaker-modal .modal-social {
display: flex;
align-items: center;
}
.speaker-modal .modal-social i {
font-size: 20px;
color: #142098;
}
#media (max-width: 1000px) {
.speaker-modal {
flex-flow: column-reverse;
}
.speaker-modal div.modal-left {
padding: 1.5rem;
}
.speaker-modal .js-close-modal {
top: 1.5rem;
right: 1.5rem;
}
}
And when I go to change the code from overflow y 'auto' to overflow y 'hidden' it starts working again. The only thing is that I need it to be auto, because I have a modal popup that comes up
I'm attempting to replace one image with another, and I know a common way is to shift one image and use a background-image. Unfortunately it's just showing completely blank for me when I do this.
Here's a code pen showing what I mean:
https://codepen.io/TheNomadicAspie/pen/JjWVbKJ
And here's the relevant CSS. Any ideas?
It's returning a 403 forbidden error when I check the console.
#main {
display: grid;
grid-template-areas:
'chat_bubble character_image'
'button_menu character_image';
grid-template-columns: 5fr 1fr;
place-items: center;
}
#chat_bubble {
grid-area: chat_bubble;
width: 70vw;
height: 70vh;
padding-left: 2vw;
padding-right: 2vw;
padding-top: 2vh;
padding-bottom: 2vh;
margin-bottom: 1vh;
}
#character_image {
grid-area: character_image;
margin-top: 2vh;
}
#character_image > img {
max-width: 100%;
}
#char_1 {
display: inline-block;
}
#button_menu {
grid-area: button_menu;
display: grid;
grid-template-columns: auto auto;
gap: 1em;
}
#media (max-width: 700px) {
#main {
grid-template-areas:
'chat_bubble chat_bubble'
'button_menu character_image';
grid-template-columns: 4fr 1fr;
}
#character_image > img {
height: 100px;
max-width: unset;
padding-top: 100px;
background-image: url('https://i.imgur.com/sRSVW2D.png') !important;
}
.container:after {
content: '';
position: absolute;
bottom: 0;
top: unset;
right: unset;
left: 75%;
width: 0;
height: 0;
border: 0.813em solid transparent;
border-top-color: #ffffff;
border-bottom: 0;
border-right: 0;
margin-left: -0.406em;
margin-bottom: -0.812em;
}
}
Instead of using background-image in media queries, change src of the image on screen resize.
window.addEventListener('resize', ()=>{
if(window.innerWidth > 700) {
image.src = 'firstimage.jpg';
} else {
image.src = 'secondimage.jpg';
}
});
Use content: url() as
#character_image > img {
height: 100px;
max-width: unset;
/* padding-top: 100px; */
content: url("https://i.imgur.com/sRSVW2D.png");
}
Codepen
I'm trying to make my page automatically go to scroll when the window is at a small height instead of trying to adjust to the height by getting squishy. I've tried different ways of using overflow, but I can't seem to find a way to make it scroll the page as a whole no matter where I put it. The codepen is here: CODEPEN Thank you in advance!
#import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Oleo+Script&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
overflow-y: scroll;
}
a {
color: #8524C6;
text-decoration: none;
}
section {
width: 100%;
height: 100vh;
color: #fff;
background: linear-gradient(-45deg, #F5D0E4, #F6D5F2, #EAD5F6, #D9D5F6, #D5E1F6, #D5ECF6);
background-size: 400% 400%;
position: relative;
animation: change 10s ease-in-out infinite;
overflow: hidden;
align-items: center;
justify-content: center;
}
h1 {
display: flex;
align-items: center;
justify-content: center;
color: #000;
font-size: 1.3em;
font-family: 'Oleo Script', cursive, 'Helvetica', sans-serif;
letter-spacing: .07rem;
transform: translateY(15vh);
}
h1 span {
display: flex;
text-align: center;
vertical-align: middle;
}
h1:hover span {
animation: animate .5s infinite;
}
#keyframes animate {
0% {
transform: translateY(0)
}
50% {
transform: translateY(-30px)
}
100% {
transform: translateY(0)
}
}
h1 span:nth-child(1) {
animation-delay: 0s;
}
h1 span:nth-child(2) {
animation-delay: .1s;
}
h1 span:nth-child(3) {
animation-delay: .2s;
}
h2 {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
vertical-align: top;
color: #000;
font-size: .4rem;
font-family: 'Press Start 2P', cursive, serif;
text-transform: uppercase;
transform: translateY(15.5vh)
}
.dancing-hamsters {
display: flex;
position: relative;
margin: auto;
align-content: center;
width: 100%;
height: 1.3rem;
width: 5.1rem;
transform: translateY(18vh);
z-index: 1;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #d3d3d3;
align-content: center;
position: absolute;
top: 50%;
bottom: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50%;
height: 50%;
padding: 5px;
padding-right: 3%;
box-shadow: inset 0 0 10px #000;
}
.top-note {
/* display: flex; */
display: none;
font-family: 'Helvetica', sans-serif;
font-size: .65rem;
text-align: center;
justify-content: center;
align-items: center;
color: #000;
transform: translate(4%, -5%);
}
.box {
display: flex;
flex-direction: column;
background-color: #d3d3d3;
text-align: center;
justify-content: center;
align-items: center;
text-align: center;
transform: translateX(50%);
width: 1rem;
height: 1rem;
font-family: 'Press Start 2P', cursive, serif;
font-size: .5rem;
margin: 2rem;
}
img {
display: flex;
width: 85%;
height: 75%;
}
.container img {
cursor: url('https://i.postimg.cc/6338xsj2/oie-nr-M8-Ct-Mr-SPb-H.png'), auto;
}
.box-text {
margin-top: 10%;
cursor: url('https://i.postimg.cc/6338xsj2/oie-nr-M8-Ct-Mr-SPb-H.png'), auto;
}
.nav {
margin: auto;
text-align: center;
transform: translateY(70vh);
font-size: .5rem;
text-transform: uppercase;
line-height: .8rem;
}
.nav a {
color: #000;
font-family: 'Press Start 2P', cursive, serif;
text-shadow: 2px 2px 7px #8524C6;
}
footer {
margin: auto;
width: 100%;
height: 1rem;
font-family: Helvetica, sans-serif;
font-size: .75rem;
background-color: transparent;
border-top: 1px solid #fff;
text-align: center;
padding-top: 1rem;
bottom: 0;
transform: translateY(80vh);
}
#keyframes change {
0% {
background-position: 0 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
/* Media Queries */
#media screen and (min-width: 740px) {
h1 {
font-size: 3em;
transform: translateY(8vh);
word-spacing: 2em;
}
h2 {
font-size: 1rem;
transform: translateY(8vh);
}
.dancing-hamsters {
height: 2rem;
width: 9rem;
transform: translateY(10.5vh);
}
.container {
display: flex;
flex-direction: row;
}
.top-note {
display: none;
}
.box {
width: 15rem;
height: 15rem;
transform: translateX(15%);
font-size: .75rem;
}
.img {
width: 100%;
height: 100%;
}
.nav li {
margin: .5em;
display: inline;
text-align: center;
align-items: center;
justify-content: center;
font-size: .85rem;
}
.nav {
transform: translateY(64vh);
}
footer {
transform: translateY(75vh);
}
}
A quick solution will be to add min-height to the main section element:
section {
width: 100%;
height: 100vh;
min-height: 500px; // I just add 500px for demo
color: #fff;
background: linear-gradient(-45deg, #F5D0E4, #F6D5F2, #EAD5F6, #D9D5F6, #D5E1F6, #D5ECF6);
background-size: 400% 400%;
position: relative;
animation: change 10s ease-in-out infinite;
overflow: hidden;
align-items: center;
justify-content: center;
}
You have specified the height of the section, but with min-height you will guarantee that regardless of the screen height, your content will not get smaller than what you have set.
I have been tweaking my CSS to make my page look good on mobile and other sizes of the window. I got it to mostly look good, but the only thing I don't like is when the window is medium sized (for like a tablet) there are 2 boxes on one line and the third on the second. This looks really bad in my opinion. Is it possible when the third box gets pushed to the second line, to make all three into a column and upgrade the size of each box a bit to fill some of the empty space?
I've been looking into flex-grow/shrink and I'm not really understanding them to see if that's what I need. I also know there's a media query thing, but don't really understand that either. Here is my current page which doesn't resize: www.catherinemeza.com
Below is my tweaked code so far: (comments are old code or something I've tried to make stuff resize)
body {
background-color: #e9cffb;
margin-top: 100px;
}
.About {
font-size: 20px;
}
.Name {
width: 100%;
display: flex;
justify-content: center;
text-align: center;
}
#All {
height: 500px;
/* width: 1500px;
margin: 50px auto; */
/* border: 5px solid black; */
/* box-sizing: content-box;
width: 100%; */
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
}
#ALL > * {
flex: 1 1 0;
}
#One {
display: block;
position: relative;
margin: 1px;
width: 500px;
height: 500px;
border: 5px solid black;
/* justify-content: space-between; */
flex-wrap: wrap;
/* box-sizing: content-box;
width: 30%; */
}
/* #One p {
width: 490px;
height: 490px;
position: absolute;
bottom: -600px;
z-index: 1;
transition: 1s;
} */
/* #One:hover p {
opacity: .6;
bottom: -30px;
width: 500px;
height: 500px;
} */
.Two {
display: block;
position: relative;
margin: 1px;
width: 500px;
height: 500px;
border: 5px solid black;
/* justify-content: space-between; */
flex-wrap: wrap;
/* box-sizing: content-box;
width: 30%; */
}
/* .Two p {
width: 500px;
height: 500px;
position: absolute;
margin-left: 10px;
bottom: -600px;
z-index: 1;
transition: 1s;
text-align: center;
color: rgb(218, 202, 228);
background-color: rgb(7, 70, 21);
border: .5px green solid;
border-radius: 20px;
}
.Two:hover p {
opacity: .7;
bottom: -10px;
width: 500px;
height: 175px;
} */
#Three {
display: block;
position: relative;
margin: 1px;
width: 500px;
height: 500px;
border: 5px solid black;
/* justify-content: space-between; */
flex-wrap: wrap;
/* box-sizing: content-box;
width: 30%; */
}
/* #Three p {
width: 490px;
height: 490px;
position: absolute;
bottom: -600px;
z-index: 1;
transition: 1s;
}
#Three:hover p {
opacity: .6;
bottom: -30px;
width: 500px;
height: 500px;
}
a {
text-decoration: none;
font-size: 20px;
color: chartreuse;
} */
The link you provided doesn't work for me, but you can solve this using media queries and flexbox. What you want to do is open dev tools so you can see the current width of your page in pixels. Resize your page down to the point you want to change (for your case, when the third box goes into the second row). Create a media query for when the screen is that px or less, which you can then add styles to edit the boxes' width and layout. I included an example below.
Breaking it down, this code is saying that when the screen width is 992px or lower, make #All a column-layout and align the items at the center. Also, change the width of each box to take up 100% of its container. You can edit the styling as you wish but if you have any questions don't be afraid to ask!
#media screen and (max-width: 992px) {
#All {
flex-direction: column;
align-items: center;
}
#One, .Two, #Three {
width: 100%;
}
}