简体   繁体   English

如何使用 CSS 修复红色和绿色块?

[英]How do I fix red and green blocks with CSS ?

everyone Would like to ask at present I am making a version when the web page to slide up the red and green block to be fixed, only the yellow block can slide!大家想问一下目前我正在做一个版本当web页面向上滑动红绿块固定,只有黄块可以滑动! The current treatment on the green side is using目前绿色方面的处理方法是使用

 position:sticky;
 right:0px;
 top:100px;

The grammar keeps him fixed there, but there's a problem because if you don't give height it looks like it's position:sticky;语法让他固定在那里,但是有一个问题,因为如果你不给出高度,它看起来就像是 position:sticky; I want his height to be customizable, so I give him a height of 200px;我希望他的高度是可定制的,所以我给他的高度是 200px; As a result, when the content is too much or in RWD mode, it goes out of the green zone.结果,当内容过多或处于RWD模式时,它会超出绿色区域。

Is there a better way to fix the red and green blocks?有没有更好的方法来修复红色和绿色块?

Here's what I'm trying to do so far.到目前为止,这是我正在尝试做的事情。 https://codepen.io/hong-wei/pen/wvgbbye?editors=1100 https://codepen.io/hong-wei/pen/wvgbbye?editors=1100

Add align-items: flex-start;添加align-items: flex-start; to your .container class and remove any height value from the aside .到您的.container class 并从aside删除任何高度值。

 .wrap{ background-color: #ccc; line-height: 1.5; }.header{ position: fixed; width: 100%; background-color: #f75454; box-shadow:0px 1px 30px #212529; z-index: 1; }.header.list{ display: flex; padding:20px; justify-content:space-between; }.container{ display: flex; padding:30px; padding-top: 100px; background-color: #5c5c5c; align-items: flex-start; }.main{ flex:2; padding:20px; height: 1600px; margin:0px 20px; background-color: #f9cf5a; }.aside{ position:sticky; right:0px; top:100px; padding:20px; flex:1; width: 100%; background-color: #1ba784; color:#eef7f2; }
 <div class="wrap"> <div class="header"> <ul class="list"> <li>測試</li> <li>測試</li> </ul> </div> <div class="container"> <div class="main"> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum expedita pariatur facere repellat nobis sed modi, porro, at numquam accusantium aut consequuntur delectus ducimus atque officia dolores, Dolore quas delectus fuga accusantium quia atque esse, non, aut quae optio officia odit natus accusamus? libero iure nam. Accusantium veritatis ad repellat,</p> </div> <div class="aside"> <p>Lorem ipsum dolor sit amet. consectetur adipisicing elit. Ex assumenda officiis sunt laboriosam impedit fuga tenetur pariatur distinctio ipsum suscipit, Lorem ipsum dolor sit amet. consectetur adipisicing elit. Ex assumenda officiis sunt laboriosam impedit fuga tenetur pariatur distinctio ipsum suscipit, Lorem ipsum dolor sit amet. consectetur adipisicing elit. Ex assumenda officiis sunt laboriosam impedit fuga tenetur pariatur distinctio ipsum suscipit.</p> </div> </div> </div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Vscode 中编辑 Typescript 文件中的 css 代码时,所有文本都是红色的,我该如何解决? - When editing css code within a Typescript file in Vscode all the text is red, how do i fix this? 单击交换按钮时,如何使红色div更改背景颜色以在红色和绿色之间切换? - How do I get my red div to change background color to toggle between red and green when I click on the swap button? 如何让我的文本从红色 div 环绕到绿色 div? - How do I get my text to wrap from the red div to the green div? 如何更改我的 javascript 以便只有所选按钮为红色或绿色 - How do I change my javascript so that only the selected button is coloured red or green 如何使用表格中的单选按钮更改背景颜色。 每个单选按钮4种颜色(白色,红色,黄色,绿色) - How do i change background color using radio buttons in tables. 4 colors(white, red, yellow, green) to each radio buttons 如何将 css 类名添加到 Squarespace 中的文本块? - How do I add css class names to text blocks in Squarespace? 如何在不使用内联CSS的情况下使用彩色文本框(红色/绿色)进行Javascript表单验证? - How to make a Javascript form validation with coloured textbox (red/green) without using inline css? 如何使用 html 和 css 代码让我的红圈始终停留在绿线上? - How to make my red circle always stays on the green line using html and css code? 如何随机删除这些绿点? - How do I remove these green dots randomly? 如何将绿色 div 置于红色 div 下? - How to position green div under the red one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM