Issue
I am trying to recreate this concept app's home page with html css only. Now I want to let the "Top Categories" list go off the outer div just like the one in this picture: (To those concerned, this is not plagiarism, this is a school project of ours.)
Here's what it looks like right now (added borders for visualization):
I want for the itemlist to be a perfect square for each item (80px by 80px) with the last ones being cut by the div so the user has to scroll to see the end.
html,
body,
* {
-webkit-app-region: drag;
-webkit-user-select: none;
cursor: default;
padding: 0;
margin: 0;
}
.header {
padding: 0;
text-align: center;
font-size: 40px;
margin-top: 0px;
margin-bottom: 4px;
}
.searcharea {
margin: 10px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-content: flex-start;
}
.location {
width: 40px;
height: 40px;
border-radius: 5px;
box-shadow: 1px 1px 4px rgb(170, 170, 170);
text-align: center;
line-height: 58px;
}
.searchbar {
width: 65%;
height: 40px;
border-radius: 5px;
box-shadow: 1px 1px 4px rgb(170, 170, 170);
border: none;
padding: 0px 57px 0px 13px;
background-image: url('assets/search-icon.png');
background-position: 95% 5px;
background-repeat: no-repeat;
}
.searchbar:focus {
outline: none;
}
#location_icon {
font-size: 29px;
}
.categories {
border: 3px solid black;
width: 90%;
margin: auto;
padding: 0px 0px 10px 10px;
}
.categoriesheader {
margin-bottom: 10px;
}
.items {
position: relative;
flex-direction: row;
display: flex;
align-content: flex-start;
justify-content: space-between;
height: 80px;
border-radius: 5px;
overflow-x: scroll;
height: fit-content;
}
.itemlist {
position: inherit;
background-repeat: no-repeat;
background-size: cover;
height: 80px;
width: 80px;
border: 2px solid black
}
#item1 {
background-image: url('https://th.bing.com/th/id/OIP.MfhIfzrC6x6T1-szQkjtCgHaEo?rs=1&pid=ImgDetMain');
}
#item2 {
background-image: url('');
}
#item3 {
background-image: url('');
}
#item4 {
background-image: url('');
}
#item5 {
background-image: url('');
}
#item6 {
background-image: url('');
}
.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24
}
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<h1 class="header">FOODIFY</h1>
<div class="searcharea">
<div class="location">
<span class="material-symbols-outlined" id="location_icon">location_on</span>
</div>
<input class="searchbar" placeholder="Search for meals or area"></input>
</div>
<div class="categories">
<h2 class="categoriesheader">Top Categories</h2>
<div class="items">
<ul class="itemlist" id="item1"></ul>
<ul class="itemlist" id="item2"></ul>
<ul class="itemlist" id="item3"></ul>
<ul class="itemlist" id="item4"></ul>
<ul class="itemlist" id="item5"></ul>
<ul class="itemlist" id="item6"></ul>
</div>
</div>
Solution
.items {
width:100vw;
display: flex;
gap: 15px;
overflow-x: scroll;
height: fit-content;
}
.itemlist {
position: inherit;
background-repeat: no-repeat;
background-size: cover;
height: 80px;
min-width: 80px;
border: 2px solid black;
}
<div class="items">
<div class="itemlist" id="item1"></div>
<div class="itemlist" id="item2"></div>
<div class="itemlist" id="item3"></div>
<div class="itemlist" id="item4"></div>
<div class="itemlist" id="item5"></div>
<div class="itemlist" id="item6"></div></div>
Answered By - Gourav
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.