【问题标题】:margin at bottom not working底部边距不起作用
【发布时间】:2012-02-13 04:22:56
【问题描述】:

我对网络开发比较陌生,我只是想为自己制作一个投资组合网站。我选择使用bg stretcher 2(全屏图像滑块)作为查看图像的方法。最重要的是,我正在尝试创建一个导航菜单,尽管我在将 div 标签定位在窗口的左下角时遇到了一些麻烦,并且当窗口保持在相同的位置时被调整大小。这是我的源代码:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Jerome Lousick</title>

<link rel="stylesheet" type="text/css" href="demo/main.css" />
<link rel="stylesheet" type="text/css" href="bgstretcher.css" />

<script type="text/javascript" src="jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="bgstretcher.js"></script>

<script type="text/javascript">
$(document).ready(function(){

    //  Initialize Backgound Stretcher     
    $('BODY').bgStretcher({
        images: ['images/18.jpg', 'images/3.jpg', 'images/2.jpg', 'images/4.jpg', 'images/11.jpg', 'images/13.jpg', 'images/15.jpg'],
        imageWidth: 1024, 
        imageHeight: 768, 
        slideDirection: 'W',
        slideShowSpeed: 1000,
        transitionEffect: 'fade',
        sequenceMode: 'normal',
        buttonPrev: '#prev',
        buttonNext: '#next',
        pagination: '#nav',
        anchoring: 'left center',
        anchoringImg: 'left center'
    });

    $('BODY').bgStretcher.pause(); //slideshow starts paused

});
</script>

<script type="text/javascript" src="demo/main.js"></script>

<style type="text/css">
#apDiv1 {
position:absolute;
width:250px;
height:65px;
z-index:1;
left: 16px;
top: 338px;
}
#apDiv2 {
position:absolute;
width:200px;
height:51px;
z-index:2;
left: 19px;
margin-bottom: 400px;
}
#apDiv2 .nav-buttons .nav-buttons #prev, #next, #toggleAnimation {
font-family: Consolas;
color: #FFF;
font-size:10px  
}
</style>

</head>
<body>
  <div id="apDiv1"><img src="images/logo.png" alt="" width="244" height="59" /></div>
  <div id="apDiv2">
    <p><span class="nav-buttons"><span class="nav-buttons"><a href="javascript:;"    id="prev">Back |</a></span> <a href="javascript:;" id="next">Next</a></span></p>
    <p>&nbsp;</p>
  </div>
</body>
</html>

【问题讨论】:

    标签: jquery html css positioning margins


    【解决方案1】:

    如果你想让 apDiv2 出现在窗口的左下角,你可以试试这个...

    #apDiv2 {
     position:absolute;
     width:200px;
     height:51px;
     z-index:2;
     left: 19px;
     bottom: 19px; /*this would be how far from the bottom you want it positioned*/
    

    }

    另外,如果您希望导航菜单在滚动时浮动在同一位置,您可以使用 position:fixed 而不是 position:absolute。

    【讨论】:

      猜你喜欢
      • 2013-08-22
      • 1970-01-01
      • 2015-02-19
      • 2015-12-02
      • 2023-03-04
      • 2012-09-12
      • 2018-06-22
      • 2018-06-13
      相关资源
      最近更新 更多