我无法为这个问题找到一个可靠的答案.可能之前有人问过,但我无法在任何地方找到合适的解决方案.
我想要的是使我的图像全宽100%,保持纵横比并垂直居中,溢出隐藏.
这就是我所拥有的:
HTML:
<div class="img-container">
<img src="myimgurl.jpg">
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.img-container {
width: 100%;
height: 200px;
max-height: 240px;
overflow: hidden;
margin: 0;
position: relative;
}
.img-container img {
position:absolute;
vertical-align: middle;
max-width: 100%;
}
Run Code Online (Sandbox Code Playgroud) 我已经看到了几个不同的示例,说明如何使用Phonegap File API将文件从一个目录复制到另一个目录,但是无法将文件从我的应用程序文件夹复制到根目录中的现有文件夹.File API文档非常模糊,我一直在应用程序目录中找不到文件.
我可以使用root.toURL()访问sdcard根文件夹文件:/// storage/emulated/0 /并读取和写入它,我似乎无法访问我的应用程序文件夹.
Phonegap Build配置文件中的权限.
<gap:plugin name="org.apache.cordova.file" version="1.3.1" />
<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
Run Code Online (Sandbox Code Playgroud)
任何帮助或示例都会很棒.
谢谢,
RG
wwwPath = cordova.file.applicationDirectory;
var fp = "temp/myfile.txt";
var fileDestPath = "tempFolder/";
function copyFile(){
var basePath = wwwPath+fp;
window.resolveLocalFileSystemURL(basePath, function(fileEntry){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
var copyToPath = fileSystem.root.toURL()+fileDestPath;
fileEntry.copyTo(copyToPath, 'newFileName.txt', function(){
alert("file copy success");
},fileCopyFail);
},fileCopyFail);
},fileCopyFail);
function fileCopyFail(error) {
alert(error);
}
Run Code Online (Sandbox Code Playgroud)