div+css ul 导航条 怎么让li在固定位置上出现

如题所述

用绝对定位

position:absolute;

top,bottom,left,right指定固定位置


<!DOCTYPE html>

<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

</head>


<body>

<style>

.demo1{

width:300px;

height:200px;

display:block;

background:pink;

position:absolute;

top:20px;

left:50px;

}

.demo2{

width:300px;

height:200px;

display:block;

background:blue;

position:absolute;

top:400px;

right:140px;

}

</style>

<ul>

  <li class="demo1">demo1</li>

  <li class="demo2">demo2</li>


</ul>


</body>

</html>

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-06-12
问的太模糊了,如果是整体,那可以控制UL的位置,如果是单独LI,那也可以 给个class 或ID 单独布局,比如 position 或margin padding
第2个回答  推荐于2018-03-06
1:css里面fixed,可以固定在以屏幕为坐标的地点
2:在或者用父元素position:relative;子元素:position:absolute;的方式进行绝对定位.
我认为你是第一种情况,想做一个漂浮起来的导航栏是吧?本回答被网友采纳
第3个回答  2015-11-10
将外层div css样式中,position属性设置成absolute,调整top,left
第4个回答  2012-06-16
说具体点
相似回答