Blazor component flex lines go outside of the component layout - html

I created blazor calendar component which consists of two parts Header and weekview components. The component flex lines go beyond the component itself and I could not figure out Why? I have attached a screenshot of the issue.
Header (Calendar Component) code
<div class="maincontainer">
<div class="viewtitle">Augest 2022</div>
<div class="lbuttons">
<button class="button"><</button>
<button class="button">></button>
<button class="button">Today</button>
</div>
<div class="mbuttons">
<label class="datelabel">Monady, Augest 21, 2022</label>
<input class="dateinput" type="datetime-local" id="schedule-time"
name="schedule-time" value="2022-06-12T19:30"
min="2022-06-07T00:00" max="2022-06-14T00:00">
<input class="button" type="button" id="btnsubmit" value="Submit">
</div>
<div class="rbuttons">
<button class="button" #onclick="#(() => DayView_Click())" #onclick:stopPropagation="true">Day</button>
<button class="button" #onclick="#(() => WeekView_Click())" #onclick:stopPropagation="true">Week</button>
<button class="button" #onclick="#(() => MonthView_Click())" #onclick:stopPropagation="true">Month</button>
</div>
</div>
#switch (CurrentView)
{
case CalendarViewOption.MonthView:
<MonthViewComponent></MonthViewComponent>
break;
case CalendarViewOption.DayView:
<DayViewComponent></DayViewComponent>
break;
case CalendarViewOption.WeekView:
<WeekViewComponent></WeekViewComponent>
break;
}
CSS
body {
margin: 0;
padding: 0;
}
.maincontainer {
background: #E7EAF6;
display: grid;
grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
grid-template-rows: auto
}
.viewtitle {
grid-column: 1/4;
grid-row: 1;
justify-self: center;
padding: 5px 5px 5px 5px;
color: darkblue;
font-weight: bold;
font-size: 16px;
}
.lbuttons {
grid-column: 1/2;
grid-row: 2;
justify-self: start;
}
.mbuttons {
grid-column: 2/3;
grid-row: 2;
justify-self: center;
}
.rbuttons {
grid-column: 3/4;
grid-row: 2;
justify-self: end;
}
.button {
background-color: black;
color: white;
border: 2px solid #555555;
padding: 3px;
margin: 0;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
border-radius: 5px;
cursor: pointer;
}
.button:hover {
background-color: white;
color: black;
}
.datelabel {
color: black;
font-weight: bold;
}
.dateinput {
padding: 3px 3px;
margin: 2px 0;
border: 1px solid rgb(130, 128, 128);
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
}
WeekView
<div class="calendar-container">
<div class="header">
<ul class="weekdays">
<li>Sun</li>
<li>Mon</li>
<li>Tue</li>
<li>Wed</li>
<li>Thu</li>
<li>Fri</li>
<li>Sat</li>
</ul>
<ul class="daynumbers">
<li>20</li>
<li>21</li>
<li>22</li>
<li>23</li>
<li>24</li>
<li>25</li>
<li>26</li>
</ul>
</div>
<div class="timeslots-container">
<ul class="timeslots">
<li>8<sup>am</sup></li>
<li>9<sup>am</sup></li>
<li>10<sup>am</sup></li>
<li>11<sup>am</sup></li>
<li>12<sup>pm</sup></li>
<li>4<sup>pm</sup></li>
<li>5<sup>pm</sup></li>
<li>6<sup>pm</sup></li>
<li>7<sup>pm</sup></li>
<li>8<sup>pm</sup></li>
<li>9<sup>pm</sup></li>
<li>10<sup>pm</sup></li>
</ul>
</div>
<div class="event-container">
<div class="slot slot-1">
<div class="event-staus"></div>
<span>Event A</span>
</div>
<div class="slot slot-2" style="height: 60px; grid-row: 1; grid-column: 1;">
<div class="event-staus"></div>
<span>Event A</span>
</div>
</div>
CSS
body {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
ul {
padding: 0;
margin: 0;
}
.calendar-container {
display: grid;
grid-template-columns: 50px auto;
grid-template-rows: auto;
gap: 1px 1px;
grid-template-areas:
". header"
"timeslots-container main";
background: #325288;
}
.weekdays,
.daynumbers {
display: grid;
grid-template-columns: repeat(7, 1fr);
}
.daynumbers {
min-height: 1em;
}
.weekdays {
background: #19456B;
color: white
}
.header {
background-color: gainsboro;
grid-area: header;
}
.timeslots-container {
background-color: lightgray;
grid-area: timeslots-container;
align-items: center;
}
.timeslots {
display: flex;
flex-direction: column;
align-items: center;
}
.timeslots li {
min-height: 60px;
}
.timeslots li::after {
content: "";
position: absolute;
left: 10px;
width: 100%;
height: 1px;
background: lightgray;
z-index: 1;
}
.event-container {
display: grid;
grid-template-columns: repeat(7, auto);
grid-template-rows: repeat(48, auto);
grid-area: main;
position: relative;
}
.slot {
position: absolute;
background: darkcyan;
border-radius: 5px;
z-index: 5;
color: white;
font-size: 12px;
}
.slot-1 {
height: 30px;
grid-row: 106;
grid-column: 3;
}
Screenshot

Your issue is with:
.timeslots li::after {
content: "";
position: absolute;
left: 10px;
width: 100%;
height: 1px;
background: lightgray;
z-index: 1;
}
setting it to left: 10px is a mistake and why its causing your code to look like this, because technically it is taking left: 10px on the entire page. You need to set it so that it does not overlap the li element by setting it to relative so it stays inside.
So I have done a few changes to your css.
First I added this css:
.calendar-container {
overflow: hidden;
}
Then I set the li elements to relative:
.timeslots li {
position: relative;
}
then I adjusted your li::after css:
.timeslots li::after {
left: 0px;
width: 3000px;
}
this should solve your problem since the ::after now stays inside the li and not the entire page, and the overflow: hidden hides any overflow that causes side-scroll.

Related

Grid Layout Overlapping Row with full height

I have started using Grid CSS and i am stuck in building a Layout using Grid system.
I am looking to build a layout where the column would overlap a row and take full height. I have attached a screenshot of the layout and what i have tried so far.
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.header {
grid-area: header;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: 120px 120px 120px;
grid-template-areas:
"header header header"
"sidebar content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
}
.overlay {
background-color: red;
z-index: 10;
grid-column: content-start / content-end;
grid-row: header-start / content-end;
}
<div class="wrapper">
<div class="box header">Header</div>
<div class="box sidebar">Sidebar</div>
<div class="overlay">Content</div>
</div>
Depending on how you want to overlap the following code works, but need to be adapted:
There's a lot of other way to do this...
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.header {
grid-area: header;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: 120px 120px 120px;
grid-template-rows: 30px 30px auto auto;
grid-template-areas:
"header header header"
"sidebar content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
grid-row: 1 / 3;
}
.sidebar {
background-color: red;
z-index: 10;
grid-row: 2 / 4;
height: 300px;
}
.overlay {
background-color: red;
z-index: 10;
grid-column: content-start / content-end;
grid-row: 3 / 4;
}
<div class="wrapper">
<div class="box header">Header</div>
<div class="box sidebar">Sidebar</div>
<div class="overlay">Content</div>
</div>

How can I make this square-inside-square structure horizontal?

I'm trying to represent this structure horizontaly, but I'm having some issues on what should I change so that this can work properly. What I hope to achieve is that those small squares in the bottom appear the same, only verticaly, on top of each other, while the bigger square keeps it's model.
.date-grid {
width: 120px;
height: 100px;
display: flex;
flex-direction: column;
}
.node {
width: 100%;
height: 100%;
background: #e9ecef;
border: none;
padding: 0;
}
time {
display: block;
height: 75%;
font-size: 24px;
display: flex;
flex-direction: column;
justify-content: center;
}
.smallHolder {
width: 100%;
height: 25%;
display: flex;
}
.smallHolder>div {
width: 25%;
height: 100%;
flex-shrink: 0;
flex-grow: 1;
}
.next { background: #0060df; }
.last { background: #d53343; }
<div class="date-grid">
<button class="node">
<time>3</time>
<div class="smallHolder">
<div class="next"></div>
<div class="last"></div>
</div>
</button>
</div>
Is this the sort of thing you're looking for? grid is great for this sort of thing.
.date-grid {
height: 100px;
display: grid;
grid-template-columns: 120px 25px;
grid-template-rows: 1fr 1fr;
grid-template-areas: "gray next" "gray last";
padding: 0;
border-style: none;
}
.gray {
grid-area: gray;
display: grid;
place-content: center;
background: #e9ecef;
}
time {
font-size: 24px;
}
.next {
grid-area: next;
background: #0060df;
}
.last {
grid-area: last;
background: #d53343;
}
<button class="node date-grid">
<time class='gray'>3</time>
<div class="next"></div>
<div class="last"></div>
</button>

Make whole css grid netsted div clickable with anchor tag centered

I am trying to center anchor tags (Link 1, Link 2, Link 3, Link 4) in a CSS grid nested div. I also want the links to have padding around them, but it seems I have missed something. Have managed so far as below. Also, how can I achieve flexible row height for the graph 1 and graph 2 boxes without mentioning the height in the grid-template-rows?
I am trying to achieve something like this image:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', Verdana, Geneva, Tahoma, sans-serif;
}
main {
width: 98 %;
margin: 5 px 5 px;
border: 1 px solid grey;
display: grid;
color: white;
grid-template-rows: 60px 40px 300px 300px 60px;
grid-template-columns: repeat(4, 1fr);
grid-gap: 5px;
}
.div-header {
background-color: #ff4757;
display: grid;
grid-column: 1 / -1;
}
.page-navbar {
grid-template-rows: 1fr;
grid-column: 1 / -1;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10 px;
background-color: #EEF5FB;
color: #000;
}
.div-box1 {
color: #000;
border-right: 1px solid skyblue;
}
.div-link {
text-align: center;
}
.page-navbar a {
color: #000;
text-decoration: none;
}
.div-box2 {
border-right: 1px solid skyblue;
}
.div-box3 {
border-right: 1px solid skyblue;
}
.div-box4 {}
.div-main-1 {
color: #000;
background-color: lightblue;
grid-column: 1 / -1;
}
.div-main-2 {
color: #000;
background-color: lightblue;
grid-column: 1/-1;
}
.div-footer {
background-color: steelblue;
grid-column: 1/-1;
}
nav {
width: 100%;
background-color: steelblue;
padding-left: 30px;
padding-right: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: inline-block;
}
.nav-links {
list-style: none;
display: inline-block;
display: flex;
}
.nav-item a {
padding: 10px 15px;
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
<main>
<div class="div-header">
<nav>
<a href="#" class="logo">
<img src="water_drop_black_24dp.svg" alt="logo" />
</a>
<ul class="nav-links">
<li class="nav-item">Page 1</li>
<li class="nav-item">Page 2</li>
<li class="nav-item">Profile</li>
<li class="nav-item">Logout</li>
</ul>
</nav>
</div>
<div class="page-navbar">
<div class="div-box1">
Link 1
</div>
<div class="div-box2">
Link 2
</div>
<div class="div-box3">
Link 3
</div>
<div class="div-box4">
Link 4
</div>
</div>
<div class="div-main-1">Chart 1</div>
<div class="div-main-2">Chart 2</div>
<div class="div-footer">Footer</div>
</main>

Align a div container at the bottom of an image

I can't align a div container at the bottom of an image.
What I've tried is editing the attribute position of the image and set it's value to "relative".
Explaining this is a little bit difficult, but I got html and css code snippets with a little preview:
codepen.io/Proudyy/pen/PoOjYpK
(it's not 84 lines long, so not too much in my opinion)
This is how it should look like:
https://imgur.com/a/LShx2cM
set position: absolute for .skin-item-footer and position: relative on it's parent div. Check below code
.skin-item-splashart {
width: 100%;
border-radius: 12px;
position: relative;
}
.skin-item-footer-left-container {
grid-column: 1;
display: grid;
grid-template-rows: repeat(2, auto);
align-self: start;
height: 100%;
}
.skin-item-footer-right-container {
grid-column: 2;
display: grid;
align-items: center;
justify-content: end;
align-self: end;
height: 100%;
}
.skin-item-default-name {
font-size: 24px;
font-weight: bold;
margin-left: 3vh;
}
.skin-item-name {
font-size: 18px;
color: gainsboro;
margin: 0;
margin-left: 3vh;
grid-row: 1;
}
.skin-item-cost {
display: grid;
grid-row: 2;
grid-template-columns: repeat(2, auto);
grid-template-rows: 1fr;
}
.skin-item-cost-value {
color: gainsboro;
grid-column: 1;
margin: 0;
}
.skin-item-cost-icon {
grid-column: 2;
margin: 0;
}
.skin-item-save-icon {
cursor: pointer;
margin-right: 2vh;
}
.skin-item {
background-color: rgb(0, 40, 75);
margin: 15px;
border-radius: 12px;
height: auto;
width: 50%;
position: relative;
}
img{
max-width: 100%;
}
.skin-item-footer {
background-color: rgba(0, 0, 0, 0.4);
border-radius: 0 0 12px 12px;
position: absolute;
bottom: 0;
height: auto;
width: 100%;
}
<div class="skin-item">
<img class="skin-item-splashart" src="https://cdn.communitydragon.org/latest/champion/1/splash-art/skin/1"/>
<div class="skin-item-footer">
<div class="skin-item-footer-left-container">
<p class="skin-item-name">SkinName</p>
<div class="skin-item-cost">
<img class="skin-item-cost-icon" src="https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-static-assets/global/default/images/icon-rp-24.png"/>
<p class="skin-item-cost-value">Spaceholder</p>
</div>
</div>
<div class="skin-item-footer-right-container">
<img class="skin-item-save-icon" src="https://img.icons8.com/color/32/000000/save--v1.png"/>
</div>
</div>
</div>

Border after each row in CSS Grid

I'm trying to make a border-bottom after each row using CSS grid with the content aligned to center. I can't get my head around it.
I want .line to fill the width of the entire .wrapper container.
How can I achieve that?
Here is the code:
* {
box-sizing: border-box;
}
.outer {
width: 80%;
margin: 0 auto;
}
.wrapper {
border: 2px solid #f76707;
border-radius: 5px;
background-color: #fff4e6;
display: grid;
grid-template-columns: repeat(3, auto) max-content;
justify-content: center;
}
.wrapper>div:not(.line) {
border: 2px solid #ffa94d;
border-radius: 5px;
background-color: #ffd8a8;
padding: 1em;
color: #d9480f;
}
.line {
grid-column-start: 1;
grid-column-end: 6;
height: 2px;
border-bottom: 1px solid black;
width: 100%;
}
<div class="outer">
<div class="wrapper">
<div>1111111</div>
<div>222</div>
<div>3333333333</div>
<div class="line"></div>
<div>4444</div>
<div>555555555</div>
<div>99999999999</div>
</div>
</div>
Instead of justify-content to center content you could add additional columns before and after your content, both with 1fr.
Then position the first div and the div after .line to the start at the second column.
Fiddle
* {
box-sizing: border-box;
}
.outer {
width: 80%;
margin: 0 auto;
}
.wrapper {
border: 2px solid #f76707;
border-radius: 5px;
background-color: #fff4e6;
display: grid;
grid-template-columns: 1fr repeat(3, auto) 1fr;
}
.wrapper>div:not(.line) {
border: 2px solid #ffa94d;
border-radius: 5px;
background-color: #ffd8a8;
padding: 1em;
color: #d9480f;
}
.wrapper > div:first-of-type,
.line + div {
grid-column: 2;
}
.line {
grid-column: 1 / -1;
height: 1px;
background: black;
}
<div class="outer">
<div class="wrapper">
<div>1111111</div>
<div>222</div>
<div>3333333333</div>
<div class="line"></div>
<div>4444</div>
<div>555555555</div>
<div>99999999999</div>
</div>
</div>
Here's a responsive solution that works with a variable number of items and without adding silly hard coded divs. Basically every item has a line below, the complicated part is determining the last row items which must not have a line. The example uses flex-box (and LESS) but that's not relevant here, it would also work with grid.
.grid {
display: flex;
}
.grid-item{
position: relative;
.one-col{
flex-basis: 100%/1;
&:nth-last-child(1){
&:after{ border-bottom: 0; }
}
}
.two-cols{
flex-basis: 100%/2;
&:nth-last-child(1),
&:nth-last-child(2):nth-child(odd){
&:after{ border-bottom: 0; }
}
}
.three-cols{
flex-basis: 100%/3;
&:nth-last-child(1),
&:nth-last-child(2):nth-child(3n+1),
&:nth-last-child(2):nth-child(3n+2),
&:nth-last-child(3):nth-child(3n+1){
&:after{ border-bottom: 0; }
}
}
.four-cols{
flex-basis: 100%/4;
&:nth-last-child(1),
&:nth-last-child(2):nth-child(4n+1),
&:nth-last-child(2):nth-child(4n+2),
&:nth-last-child(2):nth-child(4n+3),
&:nth-last-child(3):nth-child(4n+1),
&:nth-last-child(3):nth-child(4n+2),
&:nth-last-child(4):nth-child(4n+1){
&:after{ border-bottom: 0; }
}
}
#media screen and (max-width: #screen__sm) {
.grid-item .one-col;
}
#media screen and (min-width: #screen__sm) and (max-width: (#screen__md - 1)) {
.grid-item .two-cols;
}
#media screen and (min-width: #screen__md) and (max-width: (#screen__lg - 1)) {
.grid-item .three-cols;
}
#media screen and (min-width: #screen__lg) {
.grid-item .four-cols;
}
&:after{
content: "";
display: block;
position: absolute;
left: 0;
right: 0;
bottom: 0;
border-bottom: solid 1px black;
}
I had some success by using nth-of-type and switching the line to a different type (<span>).
I also added a first and sixth column for the line to span,
while the other items only occupy column 2-5.
* {
box-sizing: border-box;
}
.outer {
width: 80%;
margin: 0 auto;
}
.wrapper {
border: 2px solid #f76707;
border-radius: 5px;
background-color: #fff4e6;
display: grid;
grid-template-columns: 1fr repeat(3, auto) 1fr;
justify-content: center;
}
.wrapper>div {
border: 2px solid #ffa94d;
border-radius: 5px;
background-color: #ffd8a8;
padding: 1em;
color: #d9480f;
}
.wrapper>div:nth-of-type(3n+1) {
grid-column: 2;
}
.line {
grid-column: 1/6;
height: 2px;
border-bottom: 1px solid black;
}
<div class="outer">
<div class="wrapper">
<div>1111111</div>
<div>222</div>
<div>3333333333</div>
<span class="line"></span>
<div>4444</div>
<div>555555555</div>
<div>6666666</div>
<span class="line"></span>
<div>77777</div>
<div>888888888</div>
<div>99</div>
</div>
</div>