问题
Looking for the View Button to be locked to the bottom, using position:absolute;
would cause the price to merge into the View Button.
https://jsfiddle.net/kieranbs96/pj8emf0a/
a.view-button {
float: left;
padding: 7px 30px;
background: #e35f00;
color: #ffffff;
text-transform: uppercase;
}
.offer, .recommendation {
float: left;
flex: 1 0 32%;
margin: 0 0.3%;
width: 32%;
position: relative;
}
Any questions please ask.
回答1:
You need to make your div.offer
box a (nested) flex container in column-direction. Then pin the view button to the bottom with a flex auto
margin.
.offer, .recommendation {
float: left;
flex: 1 0 32%;
margin: 0 0.3%;
width: 32%;
position: relative;
display: flex; /* new */
flex-direction: column; /* new */
}
a.view-button {
float: left;
padding: 7px 30px;
background: #e35f00;
color: #ffffff;
text-transform: uppercase;
position: relative;
bottom: 0;
left: 0;
margin-top: auto; /* new */
}
revised fiddle
A few more things to keep in mind:
Flex layout exists only between parent and child.
Floats are ignored in a flex container.
Avoid using percentages for margin and padding in a flex container.
来源:https://stackoverflow.com/questions/42137339/pin-element-to-the-bottom-of-the-container