CSS Flexbox - Truncated Text in CSS Grid (Firefox only) [duplicate] - css

This question already has answers here:
Prevent content from expanding grid items
(3 answers)
Closed 5 years ago.
I can easily render a flexbox with some text and a button, where the text will shrink and truncate with an ellipsis if its container shrinks:
.titleBarCtr {
align-items: center;
display: flex;
}
.titleBar {
color: white;
background-color: green;
flex: 1;
height: 44px;
line-height: 44px;
margin: 0;
padding-left: 5px;
text-align: left;
}
.titleBarCtr .icon {
background-color: green;
border-left: 1px solid white;
color: white;
cursor: pointer;
font-size: 1.17em; /*Matches h3 elems*/
line-height: 44px;
height: 44px;
padding: 0 15px;
text-align: center;
text-decoration: none;
}
.truncatedText {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<link href="https://use.fontawesome.com/b911bcf9e2.css" rel="stylesheet"/>
<div class="titleBarCtr">
<h3 class="titleBar truncatedText">
Testing a long string that should be truncated
</h3>
<a class="icon" aria-current="false" role="button" href="#"><i class="fa fa-dashboard" aria-hidden="true" title="Load Estimation"></i></a>
</div>
However, if I attempt to render this same flexbox inside of a grid, the text will no longer truncate in Firefox (56.0.2 using Ubuntu 16.04), though this seems to work ok in Chrome still:
.root {
display: grid;
grid-template-columns: [left] 50px [controlBar] 200px [main] 3fr [toolbar] 100px [right];
grid-template-rows: [top] 52px [subHeader] 44px [main] 2fr [analysisPanel] 1fr [bottom];
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
position: absolute;
}
.analysisPanel {
box-shadow: 0 -2px 1px -1px rgba(0,0,0,0.2);
display: flex;
flex-flow: column;
grid-column-start: main;
grid-column-end: right;
grid-row-start: analysisPanel;
grid-row-end: bottom;
}
.titleBarCtr {
align-items: center;
display: flex;
}
.titleBar {
color: white;
background-color: green;
flex: 1;
height: 44px;
line-height: 44px;
margin: 0;
padding-left: 5px;
text-align: left;
}
.titleBarCtr .icon {
background-color: green;
border-left: 1px solid white;
color: white;
cursor: pointer;
font-size: 1.17em; /*Matches h3 elems*/
line-height: 44px;
height: 44px;
padding: 0 15px;
text-align: center;
text-decoration: none;
}
.truncatedText {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<link href="https://use.fontawesome.com/b911bcf9e2.css" rel="stylesheet"/>
<div class="root">
<div class="analysisPanel">
<div class="titleBarCtr">
<h3 class="titleBar truncatedText">
Testing a long string that should be truncated
</h3>
<a class="icon" aria-current="false" role="button" href="#"><i class="fa fa-dashboard" aria-hidden="true" title="Load Estimation"></i></a>
</div>
</div>
</div>
I've tried setting min-width: 0 on the titleBar element and playing with flex-basis with no luck.
Any suggestions?

Firefox seems to need a max-width set.
.analysisPanel {
max-width:100%;/* update */
}
.root {
display: grid;
grid-template-columns: [left] 50px [controlBar] 200px [main] 3fr [toolbar] 100px [right];
grid-template-rows: [top] 52px [subHeader] 44px [main] 2fr [analysisPanel] 1fr [bottom];
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
position: absolute;
}
.analysisPanel {
max-width:100%;/* update */
box-shadow: 0 -2px 1px -1px rgba(0, 0, 0, 0.2);
display: flex;
flex-flow: column;
grid-column-start: main;
grid-column-end: right;
grid-row-start: analysisPanel;
grid-row-end: bottom;
}
.titleBarCtr {
align-items: center;
display: flex;
}
.titleBar {
color: white;
background-color: green;
flex: 1;
height: 44px;
line-height: 44px;
margin: 0;
padding-left: 5px;
text-align: left;
}
.titleBarCtr .icon {
background-color: green;
border-left: 1px solid white;
color: white;
cursor: pointer;
font-size: 1.17em;
/*Matches h3 elems*/
line-height: 44px;
height: 44px;
padding: 0 15px;
text-align: center;
text-decoration: none;
}
.truncatedText {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="root">
<div class="analysisPanel">
<div class="titleBarCtr">
<h3 class="titleBar truncatedText">
Testing a long string that should be truncated
</h3>
<a class="icon" aria-current="false" role="button" href="#"><i class="fa fa-dashboard" aria-hidden="true" title="Load Estimation"></i></a>
</div>
</div>
</div>

Related

White space on the right side of the page below 400px device screen width. How to make it disappear?

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.

React fixed navbar with flexbox

so I'm trying to create my blog using the react framework, but I'm facing an issue here.
I really have been trying to tweaks settings on the css, html or even try to switch to grid instead of flexbox but I can't figure out how to make the "fixed" navbar detected by the flexbox.
Currently, the navbar works fine I guess, but the content that is supposed to be on the right, is not taking the place it should, it's taking the entire screen instead of the rigth section next to the navbar.
Some help would be highly appreciated !
body {
overflow: hidden;
height: 100vh;
top: 0;
left: 0;
margin: 0;
}
/*left box -Navbar*/
.nav-tab-text{
font-size: 1.6em;
display: block;
padding: 00px 0px 50px 0px;
text-align: center;
list-style-type: none;
display: flex;
}
.nav-tab a {
display: block;
text-align: center;
padding: 15px 18px;
text-decoration: none;
font-size: 18px;
color: aliceblue;
}
.nav-tab {
background-color: blue;
height: 100vh;
width: 18%;
border: 3px solid red;
position: fixed;
}
/*Right box - Home content*/
.home-content-container {
width: 100%;
height: 100vh;
border: 5px solid green;
}
.home-content-title {
text-align: center;
font-size: 1.7em;
text-decoration: underline;
text-decoration-thickness: 3px;
}
.home-content-featured{
border: 3px solid purple;
width: 50%;
height: 50%;
align-self: center;
margin-top: 3%;
}
.test{
display: flex;
}
function Navbar() {
return (
<div className="flex-container">
{/*left box - Navbar*/}
<nav className="nav-tab">
Home
Articles
Archives
About
</nav>
{/*Right box - Home content*/}
<div className="home-content-container">
<div className="home-content-title">
<h3>Name</h3>
</div>
<div className="home-content-featured">
<p>1</p>
</div>
</div>
<div className="test">
<p>2</p>
</div>
</div>
);
}
export default Navbar;
import Navbar from "./components/Navbar";
function App() {
return (
<div>
<Navbar />
</div>
);
}
export default App;
body {
overflow: hidden;
top: 0;
left: 0;
margin: 0;
}
/*left box -Navbar*/
.flex-container{
display: flex;
flex-flow: row;
}
.nav-tab a {
display: block;
text-align: center;
padding: 15px 18px;
text-decoration: none;
font-size: 18px;
color: aliceblue;
}
.nav-tab {
background-color: blue;
height: 100vh;
width: 18%;
border: 3px solid red;
}
/*Right box - Home content*/
.home-content-container {
width: 100%;
height: 100vh;
border: 5px solid green;
display: flex;
flex-direction: column-reverse;
}
.home-content-title {
text-align: center;
font-size: 1.7em;
text-decoration: underline;
text-decoration-thickness: 3px;
}
.home-content-featured{
border: 3px solid purple;
width: 50%;
height: 50%;
margin-top: 3%;
align-self: center;
}

Minimizing data for mobile view only

I have a website that shows "cards" on a pinboard, 7 wide on a pc down to 4 wide on an ipad.
What I would like to happen is when the user views this on an iphone, the image with a class of "image eventItem" stays in the same location and the h4 "pinboard-day", the h4 "pinboard-date" and the p "pinboard-text" moves up on top of the image to the right and changes from black to white.
What I am trying to acheive is similar to an accordian, so that when the user clicks on the image on an iphone the standard view will appear as for pc etc.
I currently have over 150 events currently, so I am looking for a way to acheive this without having to re-write everything out again.
Any help would be appreciated.
Regards
Milton.
<div class="wrapper-pinboard">
<nav>
<div class="items">
<span id="all-btn" class="item active" data-name="all" >All</span>
<span class="item" data-name="site1" class="list">Site 1</span>
<span class="item" data-name="site2" class="list">Site 2</span>
<span class="item" data-name="site3" class="list">Site 3</span>
<span class="item" data-name="site4" class="list">Site 4</span>
<span class="item" data-name="site5" class="list">Site 5</span>
<span class="item" data-name="site6" class="list">Site 6</span>
</div>
</nav>
<div class="gallery">
<div class="image eventItem" date="30-10-21" id="site1" data-name="site1">
<span><img src="img/Site1-logo.jpg" alt=""></span>
<h4 id="pinboard-day">Thursday night</h4>
<h4 id="pinboard-date" >30th October</h4>
<p id="pinboard-text"><b>All Welcome</b> </p>
<br>
<p> $20 Entrance Fee
<br> Doors Open 6:00PM
<br> Headline act is -
<br> Intermission 7:30PM
<br>
<br> <b>Doors Close - 8:30PM</b>
</p>
<div class="card-bottom">
<img id="card-bottom-site1-image" src="img/site1-139x113px.jpg" alt="">
<p class="card-text-bottom">
Premises
<br>Street Address
<br>City
</p>
</div>
</div>
<div class="image eventItem" date="10-10-21" id="site2" data-name="site2">
<span><img src="img/Site2-logo.jpg" alt=""></span>
<h4 id="pinboard-day">Thursday night</h4>
<h4 id="pinboard-date" >10th October</h4>
<p id="pinboard-text"><b>All Welcome</b> </p>
<br>
<p> $30 Entrance Fee
<br> Doors Open 7:00PM
<br> Headline act is -
<br> Intermission 8:30PM
<br>
<br> <b>Doors Close - 9:30PM</b>
</p>
<div class="card-bottom">
<img id="card-bottom-site2-image" src="img/site2-139x113px.jpg" alt="">
<p class="card-text-bottom">
Premises
<br>Street Address
<br>City
</p>
</div>
</div>
</div>
</div>
CSS:
:root {
--light-blue: rgb(13, 110, 253);
--dark-blue: rgb(52, 73, 94);
--gold: rgb(255, 193, 7);
--black-mine: rgb(33, 36, 41);
--grey: rgb(108, 117, 125);
--white: #ffffff;
--black-pure: #000;
--light-red: rgb(255, 96, 85);
}
.wrapper-pinboard {
margin: 100px auto;
margin-left: 15px;
margin-right: 15px;
max-width: 100%;
}
.wrapper-pinboard .items {
display: flex;
max-width: 100%;
width: 100%;
justify-content: space-around;
}
#year-buttons .button-years {
display: flex;
max-width: 1600px;
width: 100%;
position: absolute;
justify-content: space-around;
top: 315px;
}
.items span {
padding: 7px 7px;
font-size: 18px;
font-weight: 500;
color: #34495e;
border-radius: 50px;
border: 2px solid #34495e;
transition: all 0.3s ease;
min-width: 100px;
text-align: center;
}
#all-btn {
width: 70px;
text-align: center;
}
.items span.active {
color: var(--white);
background: var(--dark-blue);
}
.items span:hover {
color: var(--white);
background: var(--dark-blue);
}
#click-photo {
color: var(--dark-blue);
font-size: 24px;
font-weight: 500;
padding-top: 20px;
text-align: center;
}
#days-clubs-btn {
width: 150px;
height: 30px;
position: absolute;
top: 160px;
left: 50px;
text-decoration: none;
color: #fff;
border: solid .5px var(--grey);
border-radius: 8px;
align-items: center;
justify-content: center;
}
#days-clubs-btn i {
text-align: center;
padding-left: 8px;
padding-top: 10px;
text-decoration: none;
align-items: center;
justify-content: center;
}
.gallery {
display: flex;
flex-wrap: wrap;
margin-top: 30px;
justify-content: space-evenly;
}
.gallery .image {
width: calc(100% / 7);
padding: 7px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: whitesmoke;
box-shadow: 6px 4px 18px;
}
.gallery #site1 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 241, 241);
box-shadow: 6px 4px 18px;
position: relative;
}
.gallery #site2 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 245, 229);
box-shadow: 6px 4px 18px;
position: relative;
}
.gallery #site3 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(220, 220, 220);
box-shadow: 6px 4px 18px;
}
.gallery #site4 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 241, 241);
box-shadow: 6px 4px 18px;
}
.gallery #site5 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(236, 237, 245);
box-shadow: 6px 4px 18px;
}
.gallery #site6 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(236, 237, 245);
box-shadow: 6px 4px 18px;
}
.gallery .image span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site1 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site2 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site3 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site4 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site5 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site6 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image img {
width: 100%;
vertical-align: middle;
border-radius: 8px;
}
.gallery .image #site1 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site2 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site3 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site4 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site5 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site6 img {
width: 100%;
vertical-align: middle;
}
.gallery .image.hide {
display: none;
}
.gallery .image.show {
animation: animate 0.4s ease;
width: calc(100% / 8);
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
position: relative;
}
/* THE DATE */
h4 {
padding-top: 10px;
text-align: center;
font-weight: 500;
font-size: 1rem;
}
/* THE TEXT */
p {
padding-bottom: 20px;
text-align: center;
font-weight: 200;
font-size: 1rem;
}
#pinboard-date {
color: var(--light-blue);
}
#pinboard-day {
color: var(--light-red);
}
#pinboard-text {
color: var(--black-pure);
}
.card-bottom {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
#card-bottom-site1-image {
width: 25%;
padding-top: 20px;
}
#card-bottom-site2-image {
width: 20%;
padding-top: 20px;
}
#card-bottom-site3-image {
width: 40%;
padding-top: 20px;
}
#card-bottom-site4-image {
width: 40%;
padding-top: 20px;
}
#card-bottom-site5-image {
width: 25%;
}
#card-bottom-site6-image {
width: 20%;
}
.card-text-bottom {
display: flex;
flex-direction: column;
font-size: 12px;
}
#card-bottom-apl2-image {
width: 33%;
height: 33%;
}

how to have a perfect responsive css circles? [duplicate]

This question already has answers here:
A grid layout with responsive squares
(5 answers)
Closed 5 years ago.
In process of learning flexbox, and confused about having perfect CSS circles that are responsive. How do I do that? As it stands, my current code has circle1, circle2, and circle3 at 100 width, and height. I don't want to hard-code their height but rather make it responsive. Is there a way to have a perfect circle in %? So it scales each time the browser is resized?
Or are media queries the only option to fix this?
Thank you for your help.
* {
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: sans-serif;
font-weight: 100;
}
body {
display: flex;
margin: 0;
flex-direction: column;
}
main {
display: flex;
flex: 1 0 100%;
/*for content and sidebar */
flex-direction: row;
}
/* main */
#content {
flex: 1 0 80%;
/* for header/logo and description */
display: flex;
flex-direction: column;
}
#description img {
display: block;
}
#header {
flex: 1 0 5%;
padding: 10px;
/* for test */
display: flex;
justify-content: center;
}
#test {
display: flex;
flex-direction: row;
}
#header h1 {
text-align: center;
font-size: 5em;
padding: 0;
margin: 0;
font-family: 'Satisfy', cursive;
}
h1 {
font-family: 'Satisfy', cursive;
}
#description {
flex: 1 0 10%;
padding: 30px;
display: flex;
}
#description p {
padding-left: 20px;
font-size: 20px;
}
#description img {
width: 250px;
height: 250px;
border-radius: 50%;
border: 6px solid #db6525;
border: 6px solid #00B2AC;
}
#name {
font-size: 35px;
color: #db6525;
font-family: 'Satisfy', cursive;
}
#test img {
display: inline;
vertical-align: text-top;
width: 100px;
height: 100px;
/* for the following image and description */
display: flex;
flex-direction: row;
align-content: center;
align-items: center;
}
#sidebar {
flex: 1 0 20%;
/* background-color: green; */
text-align: center;
line-height: 90%;
/* for sidebar contents */
display: flex;
flex-direction: column;
}
#js {
flex: 1 0 33.33333%;
/* background-color: red; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#js h1 {
font-size: 50px;
}
#forms {
flex: 1 0 33.33333%;
/* background-color: gray; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#forms h1 {
font-size: 50px;
}
#sites {
flex: 1 0 33.33333%;
/* background-color: Chartreuse; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#sites h1 {
font-size: 50px;
}
.circles {
flex: 0 0 5%;
/* for circles within */
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.circle1 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle1 h1{
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
.circle2 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle2 h1 {
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
.circle3 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle3 h1 {
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
<main>
<section id="content">
<article id="header">
<section id="test">
<h1>My Website</h1>
</section>
</article>
<article id="description">
<img src='images/profilePic.png' />
<p></p>
</article>
<article class="circles">
<div class="circle1">
<h1>Twitter</h1>
</div>
<div class="circle2">
<h1>Blog</h1>
</div>
<div class="circle3">
<h1>Contact</h1>
</div>
</article>
</section>
<section id="sidebar">
<article id="js">
<h1>Javascript</h1>
<p>Mini JS Projects</p>
<p class="subtitle">Work in progress
</article>
<article id="forms">
<h1>Free Forms</h1>
<p>Feel free to download the forms</p>
</article>
<article id="sites">
<h1>Portfolio</h1>
<p>Combination of previous work and additional sites</p>
</article>
</section>
</main>
The question now is How to have a perfect responsive css square? Because when you have a square, you will easily have a circle with border-radius: 50%. Now you can found so many solution for it in SO. Here is a nice solution with flexbox item.
.flex-container {
padding: 0;
margin: 0;
display: flex;
}
.flex-item {
background: tomato;
margin: 5px;
color: white;
flex: 1 0 auto;
border-radius: 50%;
}
.flex-item:before {
content:'';
float:left;
padding-top:100%;
}
<div class="flex-container">
<div class="flex-item ">
</div>
<div class="flex-item ">
</div>
<div class="flex-item ">
</div>
</div>
Updated answer
I reworked the flex containers to a minimal working example. The flex-items should all be set to
flex: 1 1 auto /* flex-grow flex-shrink flex-basis */
This allows the circle h1 flex-items to grow and shrink as necessary. It might be necessary to use js to obtain the height of a circle from its expanded width when you apply the example to your code.
Hope this helps.
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.circles {
/* for circles within */
display: flex;
justify-content: center;
height: 100%;
width: 100%;
}
.circle1,
.circle2,
.circle3 {
display: flex;
flex: 1 1 auto;
width: 33vw;
height: 33vw;
}
.circle1 h1,
.circle2 h1,
.circle3 h1 {
flex: 1 1 auto;
width: 100%;
height: 100%;
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius: 50%;
text-align: center;
vertical-align: middle;
}
<article class="circles">
<div class="circle1">
<h1>Twitter</h1>
</div>
<div class="circle2">
<h1>Blog</h1>
</div>
<div class="circle3">
<h1>Content</h1>
</div>
</article>

span position inside a flexbox

I'm having troubles with one of a my flex items.
I'm trying to position the 2 spans of my flex div so that one is above the other, but it looks like the properties of flex force them to be next of each other.
Here is what I'm looking to do (the date element)
and here is what I have :
#til-container #til-header #til-date-container {
display: flex;
align-items: center;
position: absolute;
top: 30px;
margin: auto;
width: 60px;
height: 60px;
border-radius: 50%;
border: 1px solid #CCC;
background: white;
}
#til-container #til-header #til-date-container #til-date {
display: flex;
align-items: center;
position: relative;
margin: auto;
width: 52px;
height: 52px;
border-radius: 50%;
background: #d24949;
color: #FFF;
font-family: 'Lato', sans-serif;
text-transform: uppercase;
font-weight: 900;
text-align: center;
}
#til-container #til-header #til-date-container #til-day {
font-size: 20px;
}
#til-container #til-header #til-date-container #til-month {
font-size: 10px;
}
<div id="til-container">
<div id="til-header">
<div id="til-date-container">
<div id="til-date">
<span id="til-day">25</span>
<br/>
<span id="til-month">dec</span>
</div>
</div>
</div>
</div>
I've tried several things such has displaying the spans as blocks so they take the full width of the container and force the next span to position below the first one, but that wouldn't work. Any ideas ?
Using flex, you could add to #til-date
flex-direction: column;
justify-content: center;
I edited your snippet to add it :
#til-container #til-header #til-date-container {
display: flex;
align-items: center;
position: absolute;
top: 30px;
margin: auto;
width: 60px;
height: 60px;
border-radius: 50%;
border: 1px solid #CCC;
background: white;
}
#til-container #til-header #til-date-container #til-date {
display: flex;
align-items: center;
position: relative;
margin: auto;
width: 52px;
height: 52px;
border-radius: 50%;
background: #d24949;
color: #FFF;
font-family: 'Lato', sans-serif;
text-transform: uppercase;
font-weight: 900;
text-align: center;
/* Added */
flex-direction: column;
justify-content: center;
}
#til-container #til-header #til-date-container #til-day {
font-size: 20px;
}
#til-container #til-header #til-date-container #til-month {
font-size: 10px;
}
<div id="til-container">
<div id="til-header">
<div id="til-date-container">
<div id="til-date">
<span id="til-day">25</span>
<br/>
<span id="til-month">dec</span>
</div>
</div>
</div>
</div>

Resources