1
我有一個簡單的HTML與下面的代碼:如何縮小html頁面中的圖片大小?
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="English">
<head>
<link href="../Styles/design.css" rel="stylesheet" type="text/css" />
<title>Image</title>
<style type="text/css">
@page
{
margin: 0;
padding: 0;
}
</style>
</head>
<body style="margin: 0; padding: 0; oeb-column-number: 1;">
<div style="width: 100%; height: 100%; margin: 0; padding: 0; text-align: center;"><img alt="main" id="mainImage" src="../images/Image.jpg" style="height: 100%; max-width: 100%; max-height: 100%; padding: 0; margin: 0;" /></div>
</body>
</html>
在一個文件夾中我有Image.jpg
文件
那是可以添加使用Objective-C的CSS規則,將img
標籤寬度和高度?請幫幫我。
我試過這段代碼,但它不適合我。
NSString *setImageRule = [NSString stringWithFormat:@"addCSSRule('img', 'max-width: %fpx; height: %fpx;')", self.webView.frame.size.width*0.75,self.webView.frame.size.height*0.75];
[webView stringByEvaluatingJavaScriptFromString:setImageRule];
爲什麼你在你的html中使用CSS?改爲使用樣式表。 –
我認爲只要設置寬度和高度會有幫助,不是嗎? – Shinigamae
不,我必須在這裏注入此代碼,其他明智的其餘項目不會工作 – Navi