我有一个容器元素,其中包含一些其他元素,但根据屏幕大小,它们的某些部分在各个部分莫名其妙地被切断了。当 HTML 页面的宽度调整(通过单击并拖动它)时,您可以在我的代码沙箱链接上观察行为。如何确保只渲染主容器边框,而子元素没有任何影响?
https://codesandbox.io/s/focused-tree-ms4f2
import React from "react";
import styled from "styled-components";
const StyledTextBox = styled.div`
height: 15vh;
width: 30vw;
display: flex;
flex-direction: column;
margin: 0 auto;
border: 1px solid black;
background-color: #fff;
> * {
box-sizing: border-box;
}
`;
const InputBox = styled.span`
height: 35%;
width: 100%;
display: flex;
border: none;
outline: none;
`;
const UserInput = styled.input`
height: 100%;
width: 90%;
border: none;
outline: none;
`;
const SolutionBox = styled.div`
height: 35%;
width: 100%;
border: none;
outline: none;
`;
const StyledKeyboard = styled.span`
height: 30%;
width: 100%;
position: relative;
background-color: #DCDCDC;
box-sizing: border-box;
display: flex;
`
export default function App() {
return (
<StyledTextBox>
<InputBox>
<UserInput />
</InputBox>
<SolutionBox/>
<StyledKeyboard/>
</StyledTextBox>
);
}
凤凰求蛊
婷婷同学_
一只萌萌小番薯
相关分类