score:4
Accepted answer
the div is still overflowing, you can add overflow: hidden
to div 2 to "hide" it when the parent div shrinks.
#two {
height: 100px;
background-color: yellow;
position: absolute;
z-index: 1;
transition: all 1.5s ease-in-out;
overflow: hidden; // <----- hide any overflow
}
#one {
height: 200px;
background-color: green;
}
#two {
height: 100px;
background-color: yellow;
position: absolute;
z-index: 1;
transition: all 1.5s ease-in-out;
overflow: hidden;
}
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<div id="root"></div>
<div id="container"></div>
<script type="text/babel">
const hide = () => { var elem = document.getelementbyid("two"); elem.style.height = "0px"; }; reactdom.render(
<div id="one">
<h1>this is div one</h1>
<div id="two">
<h1>why this h1 is not hidden after the click</h1>
<button onclick={hide} id="hide">click me</button>
</div>
<div id="three">
<h1>this is div three</h1>
</div>
</div>, document.getelementbyid('container') )
</script>
Source: stackoverflow.com
Related Query
- In React a div has an height of a zero, then why its children are still showing on the screen
- when multiple React DOM components are used without outer div then JSX won't compile
- How can a React component measure an unknown number of children individually, then modify layout based on height
- React - How to get height of the particular div if you know its class
- React and Redux: Are there any performance issues/possible side effects with passing a parent component as a prop to its children
- Why objects are not valid as react children? What are valid children in react and why?
- Child component still displays even though parent has height of zero
- React App - Why m count down is showing a dot whent the hours are equals to zero? And my minute is not 00 when pass of 59
- Why is it not deleting data from mongoDB but still its showing success Message
- Don't know why the two functions are showing undefined in React
- React - How do I start a timer, then navigate a different route, then come back and have the timer still in sync with its original countdown?
- Why are Fragments in React 16 better than container divs?
- Why does React warn against an contentEditable component having children managed by React?
- React still showing errors after catching with ErrorBoundary
- My Redux state has changed, why doesn't React trigger a re-render?
- Why does React have a server on its own?
- Why am I getting Warning: Functions are not valid as a React child?
- Why is React Webpack production build showing Blank page?
- Why are React props immutable?
- Why Code Coverage in react app is empty? Tried using npm run test -- --coverage. But always showing empty code coverage
- Why my font-awesome icons are being displayed big at first and then updated to the right size?
- React context is undefined when the children are rendered using this.props.children
- Why does React re-render children when the parent changes?
- If the props for a child component are unchanged, does React still re-render it?
- Why does React resolve undefined/boolean/null to string only when they are variables?
- Why does react class component always need to call super(props) in its constructor?
- Why props in React are read only?
- Why React's PureComponent is recommended to have all its children "pure"
- Typing a React component that clones its children to add extra props in TypeScript
- I can't understand why components with 'connect()' are stateful in react
More Query from same tag
- React why my clearInterval cannot stop setInterval?
- esModuleInterop flag set, still getting default import error
- Add padding-top in react-virtualized <List />
- TypeError: Object(...) is not a function Redux Store
- react-export-excel download from onClick handler
- Invalid hook call. Hooks can only be called inside of the body of a function component using react-apollo
- How to filter and map a list of items by targeting a property with javascript
- Grommet - custom component in FormField
- Storing layout for my react app in local storage not working
- How to fix componentDidUpdate sending request over and over again
- How do I set the current component state from the data received as props from the parent component?
- Manage react apollo with redux observable
- React : call async method from same file
- How to access data from a dynamic Table
- Typescript: Discriminated Union with value in function parameter resolves to 'any'
- Select in ReactJS is picking up previous value after API call at onChange function?
- How to control react-bootstrap carousel with custom buttons?
- One step delay while using ShouldComponentUpdate()
- TypeScript + useRef<X|Y>: Type X is not assignable to type Y
- bind function in react component
- Formik validate react Rating component
- Electron js : Right Click is not registering
- How to resolve the validateDOMNesting(...): <form> cannot appear as a descendant of <form> error React JS
- Update an specific value inside the state with the reducer
- Automatic Deep Sub-Route Redirecting in React-Router
- Connect a normal function to Redux's mapDispatchToProps
- Tailwind dropdown with react
- Why stream title is not rendering when whole stream object is returned from mapStateToProps?
- React useState loading not changing
- React & Redux : cannot read property of undefined