我正在尝试在我的应用中使用可调整大小的div。为此,我必须保留用户在数据库中指定的更改。
我的问题是如何将从px给出的单位更改为其他内容?当我这样做时:
console.log(event.target.style.width)
它显示了px
中的宽度。有没有办法让它进入,例如%
或vh
/ vw
?
答案 0 :(得分:1)
怎么样:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.shwetesh.anew"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:24.2.1'
}
将宽度(以像素为单位)除以总视口宽度,然后乘以100得到一个百分比。