㈠ js如何根據不同屏幕的大小,獲得頁面高度,自動調整列表高度
varwin_w=$(window).width();//獲取寬度
varwin_h=$(window).height();//獲取高度
如果你想要匹配高度,那麼,就是頁面專剛剛打開其實沒有數據,屬是等頁面打開,計算了屏幕高度之後,再根據每條數據的高度計算出條數,再利用ajax的非同步傳輸去讀取列表,然後用JS呈現在手機網頁中的。
㈡ js怎麼讓body高度自適應手機屏幕
javascript screen對象獲取屏幕寬高如alert(screen.height)
availHeight 屬性 -- 窗口可以使用的屏幕高度,單位像素
availWidth 屬性 -- 窗口可以使用的屏幕寬度,單位像素
colorDepth 屬性 -- 用戶瀏覽器表示的顏色位數,通常為32位(每像素的位數)
pixelDepth 屬性 -- 用戶瀏覽器表示的顏色位數,通常為32位(每像素的位數)(IE不支持)
height 屬性 -- 屏幕的高度,單位像素
width 屬性 -- 屏幕的寬度,單位像素
div設置定位,寬度高度設為屏幕一般半即可,至於居中的話可以絕對定位。
㈢ chartjs圖表寬高度自適應怎麼解決
win7的系統:右鍵單擊計算機--------屬性------點擊左邊「高級系統設置」------尋高級」中的「性專能」里的「設置」------找到屬「在窗口和按鈕上使用視覺樣式」,將前面的勾選去掉------應用確定即可。 不過本人不建議取消此項,因為它能影響美化效果!
㈣ js中,高度在一定范圍內自適應,超過這個范圍就出現滾動條
設置css:min-height:you min height; max-height:200px;overflow-y:auto;//加豎滾動條
你這是extjs吧,大體是這樣的,估計就是屬性名稱不一樣而已,你查查哦,我對extjs不是很了解
㈤ js怎麼獲取div自適應高度值 然後賦值給另外的div
假設div根據瀏覽器大小改變時跟著自適應改變。
那麼js就寫在瀏覽器窗口改變時,獲取div的高度值,然後賦值給需要的div。
瀏覽器改變的時候獲取值或者改變值,是有對應的js方法的
㈥ 求一段JS 獲取子元素自適應高度值並賦予其父元素相同的高度值
樓主請詳細說明,最好能貼出html和css 代碼,在線等!
因為沒有html代碼,自己寫了個基本符合樓主的需求,測試沒有太大問題,樓主只用更改下樣式就可以了。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css" media="screen">
*{
margin: 0;
padding: 0;
}
ul,li{
list-style: none;
}
.tag{
position: relative;
width: 600px;
}
.tag li{
width: auto;
float: left;
text-align: center;
line-height: 30px;
background: #ccc;
height: 30px;
padding: 0px 20px 0px 20px;
margin:0px 10px 0px 10px;
}
.tag .show{
display: none;
top: 30px;
width: 250px;
height: auto;
overflow: hidden;
position: absolute;
background: #f00;
}
.tag .show dd{
width: auto;
float: left;
line-height: 30px;
background: #ccc;
height: 30px;
padding: 0px 20px 0px 20px;
margin:2px 10px 2px 10px;
}
</style>
</head>
<body>
<div class="tag" id="show">
<ul>
<li>示例1</li>
<li>示例2</li>
<li>示例3</li>
</ul>
<div class="show">
<dl>
<dd>第一個</dd>
<dd>第一</dd>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
</dl>
</div>
<div class="show">
<dl>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
<dd>第一個第二個</dd>
</dl>
</div>
<div class="show">
<dl>
<dd>第一個</dd>
<dd>第二個</dd>
<dd>lalalal</dd>
</dl>
</div>
</div>
<script type="text/javascript">
var show = document.getElementById('show'),
nav = show.getElementsByTagName('li'),
tag = show.getElementsByTagName('div');
for(var i = 0; i < nav.length; i++) {
nav[i].index = i;
nav[i].onmouseover = function () {
showTag(this.index);
}
nav[i].onmouseout = function () {
tag[this.index].style.display = 'none';
}
}
function getClass(dom, type) {
if (dom.currentStyle) {
return dom.currentStylep[type];
}
else {
return getComputedStyle(dom,false)[type];
}
}
function getLeftPos (index) {
if (index == 0) {
return 0;
}
else {
var count = 0;
for(var i = 0; i < index; i++) {
count += parseInt(getClass(nav[i], 'width'));
count += parseInt(getClass(nav[i], 'padding-left'));
count += parseInt(getClass(nav[i], 'padding-right'));
count += parseInt(getClass(nav[i], 'margin-left'));
count += parseInt(getClass(nav[i], 'margin-right'));
}
return count += (parseInt(getClass(nav[index], 'width')) + parseInt(getClass(nav[index], 'padding-left')) + parseInt(getClass(nav[index], 'margin-left')) + parseInt(getClass(nav[index], 'margin-right')) ) /2;
}
}
function showTag(index) {
// var nWidth = parseInt(getClass(nav[index], 'width')),
// nLeftPading = parseInt(getClass(nav[index], 'padding-left')),
// nRightPading = parseInt(getClass(nav[index], 'padding-right')),
// nLeftMargin = parseInt(getClass(nav[index], 'margin-left'));
var pos = getLeftPos(index),
twow = parseInt(getClass(tag[index], 'width')) / 2,
num = pos + twow;
tag[index].style.left = pos + 'px';
tag[index].style.display = 'block';
}
</script>
</body>
</html>
㈦ JS如何設置一個div高度值隨另一個div寬度值變化而變化
window.onresize=function()
{
//你改變DIV大小的代碼
}