0
我的成分是什麼廣告如下:高度自動帶絕對位置
class Test extends React.Component {
outterDivStyles() {
return {
position: "relative",
width: "100%",
overflow: "hidden",
/*height: this.props.height || 200*/
}
}
innerDivStyles(){
return {
position: "absolute",
top: 0,
left: 0,
right: 0,
width: "1000%",
transition: "left .5s",
transitionTimingFunction: "ease"
}
}
render(){
return(
<div>
<div ref="detailsOutterDiv" className="detailsOutterDiv" style={this.outterDivStyles()}>
<div ref="detailsInnerDiv" className="detailsInnerDiv" style={this.innerDivStyles()}>
<div className="slide" ><img src="http://placehold.it/250x200" /></div>
</div>
</div>
</div>
)
}
React.render(<Test />, document.getElementById('container'));
而CSS是:
.detailsOutterDiv{
background-color: #f00;
/*height: 200px;*/ //if the height is 200px, then it's ok, but can it be done without that?
width: 300px;
display: block;
}
.slide img{
display: block;
height: auto;
}
有什麼辦法使圖像顯示與全高,如果父div沒有特定的高度?
這是jsfiddle。
撥弄不工作 –
不工作,因爲'高度:200像素;'在CSS被註釋掉。我想解決它沒有特定的寬度。 – Boky
你應該創建一個最小的例子,沒有javascript – giorgio