css - react native : Setting the width of a view equal to its height when using percentages

标签 css react-native

我有这个样式表,当我将高度设置为百分比时,我试图使它的宽度等于高度。我以下没有成功:

art: {
    height: "70%",
    width: styles.podcastArt.height,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

任何想法或方向都会有所帮助。谢谢!

最佳答案

设置宽高比:1

art: {
    height: "70%",
    aspectRatio: 1,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

关于css - react native : Setting the width of a view equal to its height when using percentages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47366871/

相关文章:

android - react-native run-android DeviceException 无法创建 ADB 桥

javascript - 使用 axios 和 fetch in react native 时出现网络错误

android - 在 Expo : Asyncstorage gets cleared when app refreshes 中 react 原生

html - 无法将我的导航栏下拉菜单设置为 "slide"

html - CSS 居中文本框

css - Phonegap Winodows Phone 8.0 和 8.1 视口(viewport)问题

android - 来自 Couchbase Lite 的 React-Native Android 图像源

css - 嵌套时重置 css 列表计数和样式

css - 自定义 SO 的片段选择背景

react-native - react 原生 0.26 : iOS and Android version support