chrome 49 版本bug: flex父元素设置flex:1 , 子元素用height:100%无法充满父元素

本文探讨了在Chrome49版本中,使用Flex布局时遇到的问题:子元素试图通过设置height:100%来填充父元素的高度,但未能完全占据由flex:1属性撑满的空间。通过一个具体的代码示例,详细分析了问题所在,并提供了在线示例供读者参考。

1
<div class="container"> 2 <div class="item"> 3 <div class="item-inner"> 4 <a> 5 Botón 6 </a> 7 </div> 8 </div> 9 10 <div class="item"> 11 <div class="item-inner"> 12 <a> 13 Botón 14 </a> 15 </div> 16 </div> 17 18 <div class="item"> 19 <div class="item-inner"> 20 <a> 21 Botón 22 </a> 23 </div> 24 </div> 25 </div>
 1 .container {
 2   height: 20em;    
 3   display: flex;
 4   flex-direction: column;
 5   border: 5px solid black
 6 }
 7 
 8 .item {
 9     flex: 1;
10     border-bottom: 1px solid white;
11 }
12 
13 .item-inner {
14     height: 100%;
15     width: 100%;
16     display: table;
17     
18 }
19 
20 a {
21     background: orange;
22     display: table-cell;
23     vertical-align: middle;
24     
25 }

代码如上,可以看到, 在chrome49版本中, item-inner设置的height:100%, 无法充满父元素flex: 1撑满的高度

link: http://jsfiddle.net/y8mboo2s/

转载于:https://www.cnblogs.com/ZengYunChun/p/9729489.html

import styled, { keyframes } from 'styled-components'; import useStore from '../../store/store'; const LoadingPage = () => { const { loading } = useStore(); return ( <> <LoadingContainer className={loading ? '' : 'loaded'}> {/* <Loader /> <div>Loading...</div> */} <LoadingLeft className={loading ? '' : 'loaded'} /> <LoadingRight className={loading ? '' : 'loaded'} /> <SpinnerBox className={loading ? '' : 'loaded'}> <div className='configure-border-1'> <div className='configure-core'></div> </div> <div className='configure-border-2'> <div className='configure-core'></div> </div> <div className='loading-word'>加载中...</div> </SpinnerBox> </LoadingContainer> </> ) } // 定义加载动画 const spin = keyframes` 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } `; // Loading 组件样式 const LoadingContainer = styled.div` display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; width: 100%; font-size: 24px; z-index: 999; transition: all 2s; opacity: 1; position: fixed; &.loaded { opacity: 0; position: absolute; z-index: -1001; } `; const Loader = styled.div` border: 8px solid rgba(255, 255, 255, 0.3); border-top: 8px solid white; border-radius: 50%; width: 60px; height: 60px; animation: ${spin} 1s linear infinite; `; const LoadingLeft = styled.div` position: fixed; z-index: 1000; width: 52%; height: 100%; background: #37474f; left: 0; transition: all 1s; &.loaded { transform: translate(-100%, 0); } ` const LoadingRight = styled.div` position: fixed; z-index: 1000; width: 52%; height: 100%; background: #37474f; right: 0; transition: all 1s; &.loaded { transform: translate(100%, 0); } ` const SpinnerBox = styled.div` position: fixed; z-index: 1001; opacity: 1; transition: all .3s; &.loaded { opacity: 0; } .configure-border-1 { position: absolute; padding: 3px; width: 115px; height: 115px; background: #ffab91; animation: configure-clockwise 3s ease-in-out 0s infinite alternate; .configure-core { width: 100%; height: 100%; background: #37474f; } } .configure-border-2 { left: -115px; padding: 3px; width: 115px; height: 115px; background: #3ff9dc; transform: rotate(45deg); animation: configure-xclockwise 3s ease-in-out 0s infinite alternate; .configure-core { width: 100%; height: 100%; background: #37474f; } } .loading-word { position: absolute; color: #eff; font-size: 16px; top: 50%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; } ` export default LoadingPage出现这个bug tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up. This can happen if a SSR-ed Client Component used:
最新发布
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值