ฉันกำลังพยายามกำหนดพฤติกรรมเริ่มต้นบางอย่างสำหรับกริด จากนั้นแทนที่พฤติกรรมเหล่านั้นที่เบรกพอยต์เฉพาะ ในตัวอย่างต่อไปนี้ ฉันต้องการให้ div สองตัวซ้อนกัน โดยแก้ไขการตั้งค่า gutter เล็กน้อยจากค่าเริ่มต้น จากนั้นที่ 800px ขึ้นไป ฉันต้องการให้ div ซ้อนกันติดกัน ส่วนที่สองไม่เกิดขึ้น ดูเหมือนว่าการตั้งค่าระยะขอบบางอย่างจากสถานการณ์ที่น้อยกว่า 800px กำลังถูกนำไปใช้กับสถานการณ์ที่มากกว่า 800px โปรดแจ้งให้เราทราบวิธีเขียนโค้ดนี้และปฏิบัติตามแนวทางปฏิบัติที่ดีที่สุดของ Susy
HTML:
<div class="container">
<div class="primary">
<p>I am Primary</p>
</div>
<div class="secondary">
<p>I am Secondary</p>
</div>
</div>
เอสซีเอสเอส:
$susy:
(
flow: ltr,
output: float,
math: fluid,
column-width: false,
container: 1200px,
container-position: center,
last-flow: to, columns: 12,
gutters: 1 / 4,
gutter-position: after,
global-box-sizing: border-box,
debug: (
image: hide,
color: rgba(#66f, 0.25),
spot: background, toggle: bottom right)
);
* {
@include box-sizing(border-box);
}
.container{
@include container;
}
.primary{
background-color: red;
}
.secondary{
background-color: blue;
}
// Mobile first layout with slightly different
// gutter settings from default
@include with-layout(12 0.5 split){
.primary{
@include span(12);
}
.secondary{
@include span(12);
}
}
// this layout should take over at 800px and above
// and share a row but instead boxes end up on different
// rows
@include susy-breakpoint(800px, $susy)
{
.primary{
@include span(first 6);
}
.secondary{
@include span(last 6);
}
}
ฉันยังได้สร้างตัวอย่าง codepen ที่สามารถพบได้ที่นี่: