A. 如何用js來控制div高度的自適應
首先你得有個高寬比(比例),根據這個比,用js計算就是了。
function resizeHeight(id,size){
var ele = document.getElementById(id);
var width = ele.offsetWidth;
ele.style.height = size*width+"px";
}
說明:id是div的id(String),回size是高寬比答(Number)。
調用:
resizeHeight("youId",0.5);
window.onresize = resizeHeight("youId",0.5);
B. 在EXT JS中 如何定義樹高度使它適應屏幕高度。
建議鬧閉你用border布局塌彎扮;
var viewport = new Ext.Viewport( {
layout : '團灶border',
items : [
new Ext.Container({region : "left",width : 240,split:true,items : SBGLTree}),
new Ext.Container({region : "center",items : [SBJBXXGrid ,SBGZGrid]})
]
});
C. js怎麼讓body高度自適應手機屏幕
javascript screen對象獲取屏幕寬高如alert(screen.height)
availHeight 屬性 -- 窗口可以使用的屏幕高度,單位像素
availWidth 屬性 -- 窗口可以使用的屏幕寬度,單位像素
colorDepth 屬性 -- 用戶瀏覽器表示的顏色位數,通常為32位(每像素的位數)
pixelDepth 屬性 -- 用戶瀏覽器表示的顏色位數,通常為32位(每像素的位數)(IE不支持)
height 屬性 -- 屏幕的高度,單位像素
width 屬性 -- 屏幕的寬度,單位像素
div設置定位,寬度高度設為屏幕一般半即可,至於居中的話可以絕對定位。
D. DIV CSS 如何讓網頁中的某DIV自動適應屏幕高度自己變如下圖
1、首先創建或者打開我們的web項目,新建一個html文件和css文件即可,如圖所示。
E. .net iframe 自適應高度JS代碼
var winWidth = 0;
var winHeight = 0;
function findDimensions() // 函數:獲取尺寸
{
/薯模/ 獲取窗口寬度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
// 獲取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
// 通過深入 Document 內岩孫部對 body 進行檢測,獲取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
// 結果
var body = document.documentElement.scrollHeight;
var height = winHeight - 140;//窗體高度減去固定的高度
document.getElementById("frmain").style.height = height + "px";//給iframe定義高度,粗手鏈會適應屏幕的大小,並跟隨瀏覽器的最小化與最大化改變。
}
function switchSysBar() {
var src = document.all("frameshow").style.backgroundImage;
var bl = document.all('frmTitle').style.display;
if (bl == "") {
document.all("frameshow").style.background = "url(img/right.png) no-repeat center center";
document.all('frmTitle').style.display = "none"
}
else {
document.all("frameshow").style.background = "url(img/left.png) no-repeat center center";
document.all('frmTitle').style.display = ""
}
}
findDimensions();
// 調用函數,獲取數值
window.onresize = findDimensions;
//將此js腳本放到頁面的最下邊。
F. div自適應高度問題。。通過js來實現
可以不用js來實現的
用定位布局就可以的
先是左右布局,然後右邊的宏拿上邊這謹備塊固定高度
下邊的這塊就可以用蔽晌搭絕對定位top,left,right,bottom四個屬性都設置了,bottom設置為0這樣就高度自動填充剩餘的空間,調整瀏覽器也會自動調整大小的
G. js如何根據不同屏幕的大小,獲得頁面高度,自動調整列表高度
varwin_w=$(window).width();//獲取寬度
varwin_h=$(window).height();//獲取高度
如果你想要匹配高度,那麼,就是頁面專剛剛打開其實沒有數據,屬是等頁面打開,計算了屏幕高度之後,再根據每條數據的高度計算出條數,再利用ajax的非同步傳輸去讀取列表,然後用JS呈現在手機網頁中的。
H. 問一個JS或jquery自適應高度的問題 在線等
下面是關宏橡於高度自適應內容的。
可以用jq控制 在 加iframe的頁面中加
$("灶宴#iframe的ID").load(function () {
var mainheight = $(this).contents().find("body").height() + 30;
$(this).height(mainheight);
});
iframe鏈接的隱絕銀頁面中加
$(window.parent.document).find("#iframe的ID").load(function () {
var main = $(window.parent.document).find("#iframe的ID");
var thisheight = $(document).height() + 30;
main.height(thisheight);
});
I. 自適應屏幕大小的網頁是怎麼做出來的
需要通過JS和專門的css模板來控制,還需要一些腳本來控制,這個一兩句話說不明白,通過Dreamweaver可以自動生成,Dreamweaver有專門的模板(流體網格布局),這種技術稱為響應式布局,可以通過網和首雀上搜一下相關技術資料,不過這種響應性網頁布局雖然可以解決部分終端上顯示的自適應的問題,但兼容性不能做到百分之百!通常的做法還是根據不同類型終端分別做成好幾套,通過判斷終端類型來載入不同的網頁!
自適應屏幕大小的網頁元素會亂,所以一般情況下都不是自適應的。
如果想幫成自適應,用百分比定義寬度width="100%"
有按照不同解析度可以控制的css代碼
文檔寬度小於 300 像素則修改背景演示:
@media screen and (max-width: 300px) {
body {
background-color:lightblue;
}
}
一般是設置內容寬度為百分之多芹殲少那樣with=「100%」復雜點就是利用js判斷屏幕大小調用css,
TextView 的屬性 android:layout_height 和 android:layout_width 你設置的是wrap_content吧?
改成固定值如:
android:layout_height="60dip"
android:layout_width="60dip"
1.首先,在網頁代碼的頭部,加入一行viewport元標簽。
viewport是網頁默認的寬度和高度,上面這行代碼的意思是,網頁寬度默認等於屏幕寬度(width=device-width),原始縮放比例(initial-scale=1)為1.0,即網頁初始大小占屏幕面積的100%。
所有主流瀏覽器都支持這個設置,包括IE9,對於那些老式瀏覽器(主要是IE6、7、8),需要使用css3-mediaqueries.js。
2、不使用絕對寬度由於網頁會根據屏幕寬度調整布局,所以不能使用絕對寬度的布局,也不能使用具有絕對寬度的元素。這一條非常重要。具體說,CSS代碼不能指定像素寬度:width:xxx px;
只能指定百分比寬度:width: xx%;或者width:auto;
3、相對大小的字體
字體也不能使用絕對大小(px),而只能使用相對大小(em)。
body {
font: normal 100% Helvetica, Arial, sans-serif;
}
上面的代碼指定,喚早字體大小是頁面默認大小的100%,即16像素。
h1 {
font-size: 1.5em;
}
然後,h1的大小是默認大小的1.5倍,即24像素(24/16=1.5)。
*** all {
font-size: 0.875em;
}
*** all元素的大小是默認大小的0.875倍,即14像素(14/16=0.875)。
div+css來
1.首先獲得手機屏幕的寬高,也就是你要顯示的范圍的大小
豎屏
private var screenWidth:int = stage.fullScreenWidth;
private var screenHeight:int = stage.fullScreenHeight;
橫屏
private var screenWidth:int = stage.fullScreenHeight;
private var screenHeight:int = stage.fullScreenWidth;
注意的是橫屏和豎屏寬高賦值要調轉
2.獲得1個長方形的顯示空間的對象
private var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight)
把要顯示的starling初始化時候把長方形對象插入到第三個參數
myStarling = new Starling(MainGame,stage,viewPort);
設置starling中要顯示畫面的大小
myStarling.stage.stageWidth = 480;
myStarling.stage.stageHeight = 320;
完成!
J. js寫入的iframe自適應高度問題(急)
1.js控制iframe
<div id="dd">132</div>
<script>
var s = '<iframe src="javascript:document.open();document.write(\'<script>alert(1);<\/script><div>test</div>\');document.close();"></iframe>';
document.getElementById("dd").innerHTML = s
</script>
<iframe id="tst" name="tst" ></iframe>
<script>
alert(2);
var cw = window.document.getElementById('tst').contentWindow;
cw.document.open();
cw.document.write('<script>alert("test")<' + '/script>');
cw.document.write('<div>test</div>');
cw.document.close();
</script>
IE6,IE7,FF2下測試通過
2.自適應高度
在id為"ifr"的iframe內容里寫上js代碼:
<script>
function resize(){
parent.document.getElementById('ifr').style.height = document.body.scrollHeight>300?document.body.scrollHeight:300+"px";
}
window.onload=resize;
window.onresize = resize;
</script>
就能控制id為"ifr"高度至少為300px
要是回答的內容有問題,或認為不妥,請發送網路消息給我,消息內容加上本頁網址哦。。
·