HTML Icon overflow at scrolling - html

I can't figure out why the Icons are overlapping when I'm scrolling. I've already used overflow: hidden and tried various methods of hiding it. E.g with different divs that should hide one Icon.
HTML:
<div class="container">
<div class="bar">
<div class="flex-item">ID</div>
<div class="flex-item">Name</div>
<div class="flex-item">Erfassung</div>
<div class="flex-item">Frist</div>
<div class="flex-item"><img src="icons/logout_FILL0_wght400_GRAD0_opsz48.svg"></div>
</div>
<div class="data">
<?php
while($row = $result->fetch_assoc()) {
echo '<div class="dataRow" id="stat' . $row['Status'] . '">';
echo '<div class="flex-item">' . $row['ID'] . '</div>';
echo '<div class="flex-item">' . $row['Vorname'] . " " . $row['Nachname'] . '</div>';
echo '<div class="flex-item">' . $row['Erfassung'] . '</div>';
echo '<div class="flex-item">' . $row['Frist'] . '</div>';
echo '<div class="flex-item">' . '<img src="icons/arrow_forward_ios_FILL0_wght400_GRAD0_opsz48.svg" overflow="hidden">' . '</div>';
echo '</div>';
}
?>
</div>
</div>
CSS:
.container {
display: flex;
flex-direction: column;
}
.bar {
display: flex;
flex-wrap: nowrap;
font-weight: bold;
top: 0;
position: sticky;
margin-bottom: 0.5em;
background-color: #232323;
padding-block: 0.25em;
text-align: center;
align-items: center;
justify-content: center;
}
img {
width: 2.15em;
max-width: 2.15em;
filter: invert(100%);
}
.data {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
align-content: center;
text-align: center;
}
.dataRow {
display: flex;
flex-direction: row;
margin-bottom: 0.25em;
}
#stat1 {
background-color: #c0161a;
}
#stat2 {
background-color: #c4c41b;
}
#stat3 {
background-color: #4cbb2d;
}
.flex-item {
display: flex;
align-items: center;
justify-content: center;
}
.flex-item:nth-child(1) {
flex: 1;
background-color: #373737;
margin-right: 0.25em;
padding: 0.5em;
}
.flex-item:nth-child(2) {
flex: 5;
background-color: #373737;
margin-right: 0.25em;
padding: 0.5em;
}
.flex-item:nth-child(3) {
flex: 2;
background-color: #373737;
margin-right: 0.25em;
padding: 0.5em;
}
.flex-item:nth-child(4) {
flex: 2;
background-color: #373737;
margin-right: 0.25em;
padding: 0.5em;
}
.flex-item:nth-child(5) {
flex: 0.5;
background-color: #373737;
}
How can I prevent the overlapping?
The idea is that when the user is scrolling, the bar sticks to the top and nothing is overlapping. So the bar is always on top. Including the Icon.
Example

Problem: The sticky header is on the same z-index level as the content, which causes the header and content to overlap.
Solution: Tell the browser that the sticky header should be on top of the data, by using z-index. More info here.
CSS:
.container{
z-index:2;
}
.bar{
z-index:2;
}
.data{
z-index:1;
}

have you try to use flex grid? it can maybe solve the problem.

Related

When I put an image the text at right go at the bootom

it is making me crazy.
I have a nav bar where there are three div.
Each div has some text that is aligned at center both vertically and horizontally.
When I put an image ( is a svg icon of a zoom lens ) before the "search" text, it moves my text "search" at the bottom.
This is the code:
HTML
<nav>
<div id="leftside">
<img src="img/zoom-lens.png" alt="search">
search
</div>
<div id="middle">
Arkadomundo
</div>
<div id="rightside">
Sign Up
</div>
</nav>
CSS
#import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
* {
margin: 0;
padding: 0;
}
nav {
height: 70px;
width: 100%;
background-color: #241F1C;
font-family: 'Press Start 2P', cursive;
color: #FFFFFF;
display: flex;
align-items: center;
}
#leftside {
flex-grow: 1;
text-align: left;
margin-left: 10px;
}
#leftside img {
height: 50px;
}
#middle{
flex-grow: 2;
text-align: center;
}
#rightside {
flex-grow: 1;
text-align: right;
margin-right: 10px;
}
I guess it's an easy problem for you but honestly I cant find the why it happens
Your #leftside div won't automatically align its contents. Add display: flex; align-items: center; to it too, and everything will be centered vertically:
#import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
* {
margin: 0;
padding: 0;
}
nav {
height: 70px;
width: 100%;
background-color: #241F1C;
font-family: 'Press Start 2P', cursive;
color: #FFFFFF;
display: flex;
align-items: center;
}
#leftside {
flex-grow: 1;
text-align: left;
margin-left: 10px;
display: flex;
align-items: center;
}
#leftside img {
height: 50px;
}
#middle {
flex-grow: 2;
text-align: center;
}
#rightside {
flex-grow: 1;
text-align: right;
margin-right: 10px;
}
<nav>
<div id="leftside">
<img src="https://picsum.photos/80/120" alt="image"> search
</div>
<div id="middle">
Arkadomundo
</div>
<div id="rightside">
Sign Up
</div>
</nav>
Try adding display: inline-block; on your CSS for #leftside img
#leftside img {
height: 50px;
display: inline-block;
}
for fixing this, make #left-side flex container and set align-items property to
center because #left-side child's get centered. Or copy this CSS codes:
#import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
* {
margin: 0;
padding: 0;
}
nav {
height: 70px;
width: 100%;
background-color: #241F1C;
font-family: 'Press Start 2P', cursive;
color: #FFFFFF;
display: flex;
align-items: center;
}
#leftside {
flex-grow: 1;
text-align: left;
margin-left: 10px;
display: flex;
align-items: center;
}
#leftside img {
height: 50px;
}
#middle{
flex-grow: 2;
text-align: center;
}
#rightside {
flex-grow: 1;
text-align: right;
margin-right: 10px;
}
it s working if I put display flex and align items also on #leftside !
Thank you !

When phone device is on landscape mode, css starts to screw up

I'm currently making this website for a company as a student intern learning and I was wondering how I could fix this issue where my product containers and promotion containers, when flipped or on a smaller phone it does not fix and the text and or buttons are out of the container. How can I fix this? I understand media queries but I don't have a full grasp on how I can even fix this with css.
HTML (Products)
<?php
require_once 'includes/dbh-inc.php';
$current_file_name = basename($_SERVER['PHP_SELF']);
$result2 = mysqli_query($conn,"SELECT `serviceID` FROM `addService` WHERE servicePageName = '".$current_file_name."'");
$row2 = mysqli_fetch_array($result2);
$ID2 = $row2['serviceID'];
$sql = "SELECT * FROM addProduct WHERE serviceID = '$ID2'";
$result = $conn-> query($sql);
if ($result-> num_rows > 0) {
while ($row = $result-> fetch_assoc()) {
echo '<div class="product-container" style="background-image: url(data:image/jpg;base64,'.base64_encode($row['imagetmp']).')">';
echo '<div class="service-title">';
echo '<h1>'. $row["product"] .'</h1>';
echo '</div>';
echo '</div>';
}
echo '</div>';
echo '</div>';
}
?>
CSS (Products)
/* Services Section */
.services-section {
background-attachment: fixed;
background-size: cover;
background-position: center;
justify-content: center;
}
.services-section a {
}
.services-section h1 {
color: var(--clr-text);
font-size: 3.5rem;
text-decoration: underline;
}
.services-section h2 {
color: var(--clr-text);
font-size: 2.5rem;
text-decoration: underline;
}
.title-section {
display: flex;
justify-content: center;
align-items: center;
padding: 2em;
}
.services {
display: grid;
gap: 10px;
margin-top: 1em;
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
justify-items: center;
}
.service-title {
display: flex;
justify-content: center;
background-color: var(--clr-background);
border: var(--clr-bg-border);
align-items: center;
flex-direction: column;
height: fixed;
width: fixed;
}
.service-container {
border: 5px solid var(--clr-primary);
background-size: cover;
background-position: center;
background-color: black;
height: 20vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 30vh;
margin-bottom: 5vh;
}
.service-container i {
color: white;
padding: 0.5em;
float: right;
}
.service-container h1 {
color: var(--clr-text);
padding: 0.5em;
font-size: 1.5rem;
}
.service-container h2 {
color: var(--clr-text);
padding: 0.5em;
font-size: 1.5rem;
}
.service-container h1:hover {
color: var(--clr-secondary-text);
transition: ease 650ms;
}
.service-button {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
padding: 2em;
}
.service-button a {
background-color: var(--clr-primary);
color: var(--clr-text);
text-decoration: none;
font-size: 2em;
padding: 0.5em;
}
.service-button a:hover {
color: black;
background-color: yellow;
text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;
transition: ease 650ms;
}
.service-about {
display: flex;
justify-content: center;
background-color: var(--clr-background);
border: var(--clr-bg-border);
padding: 1em;
margin: 1em;
height: fixed;
width: fixed;
}
.service-about p {
color: var(--clr-text);
text-align: center;
font-size: 1.5rem;
}
.service-about span {
color: var(--clr-secondary-text);
text-align: center;
font-size: 1.5rem;
}
.service-about a {
color: var(--clr-secondary-text);
text-align: center;
font-size: 1.5rem;
}
.featured-services {
display: grid;
gap: 10px;
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
justify-items: center;
}
HTML (Promotion)
<div class="promotions">
<?php
require_once 'includes/dbh-inc.php';
$sql = "SELECT clientName, startDate, endDate FROM Clients";
$result = $conn-> query($sql);
$currentDate = date('Y-m-d');
$currentDate = date('Y-m-d', strtotime($currentDate));
$promotion;
if ($result-> num_rows > 0) {
while ($row = $result-> fetch_assoc()) {
if (($currentDate >= $row["startDate"]) && ($currentDate <= $row["endDate"])){
echo '<div class="promotion-container">';
echo '<div class="promotion-text">';
echo '<h1> '. $row["clientName"] .' is currently having a promotion.</h1>';
echo '</div>';
echo '<div class="promotion-button">';
echo '<button>Click Here</button>';
echo '</div>';
echo '</div>';
}
}
}
?>
</div>
CSS (Promotion)
/* PROMOTION PAGE */
.promotions {
min-height: 100vh;
display: grid;
color: var(--clr-text);
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
text-align: center;
justify-items: center;
margin-top: 1em;
}
.promotion-container {
border: 5px solid var(--clr-primary);
height: 20vh;
width: 30vh;
background-color: black;
}
.promotion-text h1 {
font-size: 1.15rem;
padding: 1em;
}
.promotion-button {
display: flex;
justify-content: center;
padding: 1em;
}
.promotion-button button {
color: var(--clr-text);
background-color: var(--clr-primary);
font-size: 1.15rem;
}
Image of my current issue
There are minimum two options:
You can customize your styles using flexbox or grid advantages.
You can write some styles for landscape orientation:
#media (orientation: landscape) {
// your specific styles for landscape
}
https://developer.mozilla.org/en-US/docs/Web/CSS/#media/orientation

How to place an item under another item using flxbox?

I have a JS fiddle here and it's pretty simple what I want to happen but difficult for me to execute it. In the fiddle, you notice there is a red box. I want that red box to be displayed under the text "Join Balance...". I am not sure how to do this.
Can somebody help me?
Fiddle: https://jsfiddle.net/f2h390wc/
HTML and CSS:
/* newsletter section */
#custom_html-5 {
width: 100%;
background-color: #f2f2f2;
padding-bottom: 40px;
padding-top: 20px;
margin-bottom: 70px;
padding-left: 70px !important;
padding-right: 20px !important;
}
.newsletter_inner_section {
display: flex;
}
.newsletter_gif {
width: 200px;
height: auto;
}
.newsletter_left,
.newsletter_center,
.newsletter_right {
display: inline-flex;
}
.newsletter_left {
width: auto;
}
.newsletter_center {
width: 100%;
align-items: center;
}
.newsletter_right {
background: red;
width: 40%;
justify-content: flex-end;
}
.newsletter_text_section {
color: black !important;
font-size: 24px !important;
font-weight: bold;
}
.eVEmvD.eVEmvD.eVEmvD.eVEmvD.eVEmvD.eVEmvD {
width: fit-content !important;
padding: 0 20px;
}
.fGCWnQ.fGCWnQ {
justify-content: flex-end;
}
.kvTDNe.kvTDNe {
display: unset;
}
/* Media Newsletter section only */
#media (max-width:1144px) {
#custom_html-5 {
padding-left: 20px !important;
padding-right: 20px !important;
}
.newsletter_inner_section {
width: 100% !important;
justify-content: center;
display: flex;
}
.newsletter_center,
.newsltter_right {
flex-direction: column !important;
}
}
<!-- newsletter section -->
<div class="newsletter_section">
<div class="newsletter_inner_section">
<div class="newsletter_left">
<img src="https://balancecoffee.co.uk/wp-content/themes/balancecoffeechild/img/newsletternnobkg2.gif" alt="Balance Newsletter" style="padding-right:30px;" class="newsletter_gif">
</div>
<div class="newsletter_center">
<p class="newsletter_text_section">Join Balance and get 20% off your first order</p>
</div>
<div class="newsletter_right">
<div class="newsletter_input_section">
<div class="klaviyo-form-Rrsqsh"></div>
</div>
</div>
</div>
</div>
If you want the text and the red box on the right to form a column, then they both need to be in a flexbox with flex-direction: column;.
I created a sample from scratch because there is a lot of superfluous stuff in your JSFiddle.
.group {
display: flex;
flex-direction: row;
width: 100%;
}
.content-box {
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
padding: 40px;
}
.left {
background-color: blue;
}
.right {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.top-right {
background-color: green;
}
.bottom-right {
background-color: red;
}
<div class='group'>
<div class='left content-box'>
Content
</div>
<div class='right'>
<div class='top-right content-box'>
Content
</div>
<div class='bottom-right content-box'>
Content
</div>
</div>
</div>
https://www.w3schools.com/cssref/css3_pr_flex-direction.asp
display: flex;
flex-direction: column;

Flexbox column wrap is not equal width

I've created a simple masonry layout using flexbox column wrap, however I've noticed that the column with "Film/TV" and "Pop" is significantly smaller than the others.
How can I force each column to have approximately the same width?
Here's my CSS code:
& .masonry-layout {
display: -webkit-box;
display: flex;
flex-flow: column wrap;
width: 100%;
height: 730px;
& .item {
background-repeat: no-repeat;
background-size: cover;
box-sizing: border-box;
border-radius: var(--theme-border-radius);
display: flex;
flex-direction: column;
padding: 10px;
margin: 0 5px;
margin-bottom: 10px;
& .item__content {
align-self: flex-end;
flex-direction: row;
width: 100%;
box-sizing: border-box;
color: var(--theme-color-white);
font-size: calc(var(--teft-typography-base) * 0.75);
font-weight: bold;
text-transform: uppercase;
}
& .svg {
display: flex;
flex-direction: row;
flex-grow: 2;
justify-content: center;
width: 100%;
}
}
}
Here's the HTML:
<div class="masonry-layout">
<div class="item" style="background-image:url('<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/assets/images/landing-page/browse-library/>
<div class="svg">
<?php if (!empty ( $item->svg ) ) { echo ( $item->svg ); } ?>
</div>
<div class="item__content">
<span><?php echo esc_html( $item->text ); ?></span>
</div>
</div>
</div>
When I removed the span element, everything was sized as expected.
set a minimum width ( or / and ) maximum width to keep them similar or the same size.

Build line-through style with flexbox and pseudo elements

I'm building a line-through header that can span multiple lines. Using the sample code below, is it possible to write my CSS in such a way that the left and right divs are not needed? Where they could be added as pseudo-classes to my header class?
CodePen
.container {
box-sizing: border-box;
display: flex;
place-content: center space-evenly;
align-items: center;
}
.line {
flex: 1;
height: 2px;
background: black;
}
.header {
font-size: 50px;
margin: 0 30px;
text-align: center;
}
.header-broken:after {
content: '';
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
width: 50px;
height: 5px;
flex: auto;
width: 100%;
height: 2px;
background: black;
}
<div class="container">
<div class="line"></div>
<div class="header">Normal Title<br>fdasfsaf</div>
<div class="line"></div>
</div>
It can be done with just one div, see the example below, add some margin to the pseudo elements as needed for spacing.
.container {
display: flex;
text-align: center;
}
.container:before,
.container:after {
content: "";
flex: 1;
background: linear-gradient(black, black) center / 100% 1px no-repeat;
}
<div class="container">
Normal Title<br>fdasfsaf
</div>
You can also try this.
HTML:
<div class="container">
<div class="header">
<h1>Normal Title
<br>fdasfsaf
</h1>
</div>
</div>
CSS:
.container {
display: flex;
text-align: center;
}
.header {
flex: 1;
}
.header h1 {
font-size: 50px;
margin: 0 30px;
text-align: center;
background-color: #fff;
display: inline-block;
}
.header:after {
content: '';
border-bottom: 1px solid #000;
display: block;
margin-top: -58px;
}