NOTE: All needs to be done in CSS Grid
Below is my code and a screenshot. For some reason the content is overflowing its container. All content should fit inside of the cell, but it is breaking out. That leads me to a couple questions that I will list below:
Is it possible to make the contents of a cell in this case fit the container? The content should fit inside the cell.
Also, is there a way to shrink the cells to the size of the content? For example in flex you could just set display:flex and it fits to the container automatically. I would also like to refrain from using minmax() with a static value if possible. For example grid-template-columns:repeat(auto-fit, minmax(100px, 1fr)); has a static value of 100px, but I don't ever know what that value will be. Let me know if that doens't make sense.
SCSS
.row,
.column {
display:grid;
margin:auto;
max-width:1200px;
}
.row {
grid-template-columns:repeat(12, 1fr);
grid-column-gap:120px;
.cell {
grid-column:span 12;
&.large-3 {
grid-column:span 3
}
}
}
HTML
<div class="row row-gap">
<div class="cell large-3">
<h4>Menu</h4>
<nav>
<ul>
<li>Home</li>
<li>About Shoup's</li>
<li>Shop Online</li>
<li>News Archive</li>
<li>Contact Shoups</li>
</ul>
</nav>
</div>
<div class="cell large-3">
<h4>Services</h4>
<nav>
<ul>
<li>Shoup's Catering</li>
<li>Arborwood by Shoup's</li>
<li>On The Rocks</li>
<li>Shoup's Country Store</li>
</ul>
</nav>
</div>
<div class="cell large-3">
<div class="reviews">
<div class="item flex justify-between align-center">
<div class="block">
<div class="rating flex">
#for($i = 1; $i <= $rating; $i++)
#svg('star')
#endfor
</div>
<div class="info">
<p class="name">Shoups Seasoning</p>
<p class="review">by Torie</p>
</div>
</div>
<div class="block">
<div class="image">
<img src="" alt="">
</div>
</div>
</div>
<hr>
<div class="item flex justify-between align-center">
<div class="block">
<div class="rating flex">
#for($i = 1; $i <= $rating; $i++)
#svg('star')
#endfor
</div>
<div class="info">
<p class="name">Shoups Seasoning</p>
<p class="review">by Donna Jackson</p>
</div>
</div>
<div class="block">
<div class="image">
<img src="" alt="">
</div>
</div>
</div>
</div>
</div>
<div class="cell large-3">
<h4>Contact</h4>
<p>Connect with us to receive promotional updates and specials.</p>
<div class="social">
<ul class="flex">
<li>#svg('facebook')</li>
<li>#svg('twitter')</li>
<li>#svg('linked-in')</li>
<li>#svg('google-plus')</li>
<li>#svg('pinterest')</li>
</ul>
</div>
</div>
</div>
Related
For context, here's what it looks like. In the second unordered list, I would like the items to have the same height as the items in the first unordered list even though they don't have sections 2 or 3. Is this possible using flexbox or any other type of css? I'm trying to avoid calculating heights using JS. In the snippet below, I'm using pure css, but in my actual code, I'm using less.
EDIT: I can't hard-code the height because the sections are dynamic and generated by data retrieved from an API. Additionally, I can't make them vertically scrollable.
Code:
<html>
<head>
<style>
.module {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.module .container_wrapper {
border: solid 1px;
}
.module .panes-2 {
flex: 0 0 49%;
}
.module .card {
display: inline-block;
border: solid 1px;
}
</style>
</head>
<body>
<section class="module">
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
</ul>
</div>
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
</ul>
</div>
</section>
</body>
</html>
I did a little research.
Not sure if this is what you are looking for, but using bootstrap could help:
<div class="container-fluid content-row">
<div class="row">
<div class="col-sm-12 col-lg-6">
<div class="card h-100">
… content card …
</div>
</div>
… all the other cards …
</div>
</div>
.card {
height: 500px;
overflow-y: scroll;
}
Also you can use overflow-y: auto;
I am using Semantic-UI in project. When resize a window, the width of the menu container becomes smaller then the menu items width.
You can see this effect on the Semantic-UI example page
Sample code.
body {
overflow: auto;
}
.big.block {
width: 1000px;
height: 100px;
background: red;
}
<div class="ui grid">
<div class="row">
<div class="sixteen column">
<div class="ui floated left main mini menu">
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
<div class="item">
some item
</div>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="big block">big block</div>
</div>
</div>
</div>
Example in the JSFiddle
How to fix this?
I have something like this and I need to skip first element "comment-id-1" to remove border-style on the next element "border-style". I tried to write, but it doesn't work. Is there some regex rules for css? How can I do this?
.comments-list:not(:first-child)
<div id="comments-list">
<ol class="comments-tree-listan">
<div id="comment-id-1">
<div class="border-style">
<div class="com_info">
<span class="name">Fedor</span></div>
<div class="text">
<div id="comm-id-1"><p>Some text</p></div></div>
</div>
</div>
<div id="comment-id-2">
<div class="border-style">
<div class="com_info">
<span class="name">Validim Puten</span></div>
<div class="text">
<div id="comm-id-2"><p>Text</p></div></div>
</div>
</div>
<div id="comment-id-3">...
</ol>
</div>
[id^="comment-id-"] will give you all id start with the string.
> will get the immediate child after (only one level down)
div[id^="comment-id-"]>.border-style {
border: 1px solid red;
}
<div id="comments-list">
<ol class="comments-tree-listan">
<div id="comment-id-1">
<div class="border-style">
<div class="com_info">
<span class="name">Fedor</span></div>
<div class="text">
<div id="comm-id-1"><p>Some text</p></div></div>
</div>
</div>
<div id="comment-id-2">
<div class="border-style">
<div class="com_info">
<span class="name">Validim Puten</span></div>
<div class="text">
<div id="comm-id-2"><p>Text</p></div></div>
</div>
</div>
<div id="comment-id-3">...
</ol>
</div>
my flipclock animation works well in Firefox & IE but doesn't work in Google Chrome.
HTML
<div id="tempFlipClock" data-position="LeftContent">
<div id="FlipClockContainer" class="animated" data-dbitm='ClockContainer'>
<div class="container">
<ul class="flip hoursPlay">
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
</ul>
<ul class="flip minutesPlay">
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
</ul>
<ul class="flip smallsize dnPlay">
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
<li>
<a>
<div class="up">
<div class="shadow"></div>
<div class="inn"></div>
</div>
<div class="down">
<div class="shadow"></div>
<div class="inn"></div>
</div>
</a>
</li>
</ul>
<div class="clsServerDate">
<span id="serverdate"></span>
</div>
</div>
</div>
</div>
i put the fork here ... [PS]:http://codepen.io/anon/pen/WQxREV
it work on firefox but not chrome... in chrome only display white page.. this happend after the chrome update that disable flash..
It seems like your perspective is the main culprit here. I've made changes in your CSS as:
old CSS:
ul.flip li a {
height: 100%;
-webkit-perspective: 200px;
-moz-perspective: 200px;
perspective: 200px;
}
new CSS:
ul.flip li a {
height: 100%;
width: 100%;
display: inline-block;
/* -webkit-perspective: 200px;
-moz-perspective: 200px;
perspective: 200px; */
}
As you can see I've comment-out your perspective for ul.flip li a now its working fine for both Chrome as well as FF.
Hope it will do the trick for you :)
HTML:
<div class="item">
首页
<div class="item">
项目
<div class="item">
招贤
<div class="item">
联系
</div>
</div>
</div>
</div>
SCSS:
.item{
background-color:skyblue;
#for $i from 1 through 4{
&:nth-child(#{$i}){
margin-left:$i * 10px;
}
}
}
The nth-child(3) doesn't select that.
I try to use nth-of-type, but it's only take nth-of-type(1).
Do I need to add a class in every .item ?
The correct way is to use the space since you are talking about children and not siblings
div div div {}
div div div{
background: red
}
<div class="item">
首页
<div class="item">
项目
<div class="item">
招贤
<div class="item">
联系
</div>
</div>
</div>
</div>
To use nth-child you will have to change the markup structure
div:nth-child(3){
background: red
}
<div class="item">
首页
</div>
<div class="item">
项目
</div>
<div class="item">
招贤
</div>
<div class="item">
联系
</div>