flexbox

悬停一个元素时如何影响其他元素

巧了我就是萌 提交于 2020-02-26 07:39:17
我想做的是将某个 div 悬停时,它将影响另一个 div 的属性。 例如,在 此JSFiddle演示中 ,当您将鼠标悬停在 #cube 它会更改 background-color 但是我想要的是,当我将鼠标悬停在 #container , #cube 会受到影响。 div { outline: 1px solid red; } #container { width: 200px; height: 30px; } #cube { width: 30px; height: 100%; background-color: red; } #cube:hover { width: 30px; height: 100%; background-color: blue; } <div id="container"> <div id="cube"> </div> </div> #1楼 非常感谢Mike和Robertc的有用帖子! 如果您的HTML中有两个元素,并且您想要 :hover 在一个元素上,并在另一个元素中定位样式更改,则这两个元素必须直接相关-父母,子女或兄弟姐妹。 这意味着这两个元素要么必须在另一个元素之内,要么必须都包含在同一较大的元素之内。 我想在用户浏览我的网站并将 :hover 在突出显示的术语上时在浏览器右侧的框中显示定义。 因此,我不希望将'definition'元素显示在

Using flex to achieve two rows and one column layout [duplicate]

。_饼干妹妹 提交于 2020-02-23 07:35:44
问题 This question already has answers here : Make a div span two rows in a grid (2 answers) Closed 15 days ago . I'm trying to use flexbox to achieve a column layout with an element "floated" to the right. Something like this : Thing is, I cannot alter the HTML since it's an embedded form so trying to achieve this via pure CSS. So far, I have this: .form { display: flex; flex-direction: column; text-align: center; } .form-container { display: flex; flex-direction: column; text-align: center;

Center responsive elements in horizontal scroll container

时光总嘲笑我的痴心妄想 提交于 2020-02-23 07:01:07
问题 I have created a container (red border with line denoting the center) that scrolls horizontally if there is overflow. The first child (purple block) of this container is always a button. When you click this button, it adds additional children to the container. What I am trying to do is figure out a way with pure CSS, so that the first child is always centered when the app is loaded, and the last child element in the container, if there is more than one child, can also be scrolled to the very

Stacking images with CSS Flexbox

本秂侑毒 提交于 2020-02-22 07:01:06
问题 I am learning to use CSS flexbox and I would like to render a big image on the left and two small images stacked on top of each other. How can I do this using CSS flexbox? <div class="container"> <img class="image1" src="#" alt="null"> <img class="image1" src="#" alt="null"> <img class="image3" src="#" alt="null"> </div> 回答1: I would do this like this: .container { display: flex; } .side { display: flex; flex-direction: column; } .image { display: block; margin: 5px; } <div class="container">

React-Native: Substitute for flex-basis

寵の児 提交于 2020-02-22 06:27:45
问题 The Flexbox layout has a property called flex-basis . According to CSS Tricks: This defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword. React Native apparently does not support this property. How do I work around this in RN or more specifically, how can I achieve a layout like this: In that picture, the "1", "2" etc are part of a list and should take roughly 50% of the available space so that 2 elements fit

React-Native: Substitute for flex-basis

て烟熏妆下的殇ゞ 提交于 2020-02-22 06:26:29
问题 The Flexbox layout has a property called flex-basis . According to CSS Tricks: This defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword. React Native apparently does not support this property. How do I work around this in RN or more specifically, how can I achieve a layout like this: In that picture, the "1", "2" etc are part of a list and should take roughly 50% of the available space so that 2 elements fit

React-Native: Substitute for flex-basis

自作多情 提交于 2020-02-22 06:26:07
问题 The Flexbox layout has a property called flex-basis . According to CSS Tricks: This defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword. React Native apparently does not support this property. How do I work around this in RN or more specifically, how can I achieve a layout like this: In that picture, the "1", "2" etc are part of a list and should take roughly 50% of the available space so that 2 elements fit

A flexbox grid of two flex items next to one [duplicate]

末鹿安然 提交于 2020-02-22 05:45:05
问题 This question already has answers here : Is it possible for flex items to align tightly to the items above them? (5 answers) Make a div span two rows in a grid (2 answers) Closed 2 years ago . I am trying to have one div on the left and two on the right. The bottomright should always be below the topRight div. The topRight is the only div with a variable height. I am currently trying to achieve this using flexbox als you can see in my code below. I would like to have some directions. .wrapper

Two columns flex-box layout

与世无争的帅哥 提交于 2020-02-19 09:50:27
问题 I need create layout which will contain list of items in two columns. Like i showed below: .container { border: 1px solid red; height: 300px; display: flex; flex-direction: column; justify-content: flex-start; flex-wrap: wrap; } .item { border: 1px dashed blue; height: 50px; } <div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> <div class="item">4</div> <div class="item">5</div> <div class="item">6</div> <div class="item">7</div> <div class=

problem with left sticky div inside a scrollable parent container

六眼飞鱼酱① 提交于 2020-02-14 20:29:31
问题 I have this problem - I have a container that contains some rows and in each row there is a sticky left column and then multiple other columns. Now in the example below this works for a little while but as you scroll the parent container the position sticky no longer works and it gets pushed along as you scroll. .container { overflow-x: scroll; } .row { display: flex; width: 100%; } .item { min-width: 173px; } .sticky { min-width: 250px; position: sticky; left: 0; background: red; } <div