Javascript jQuery幻灯片放映未居中
我用HTML/asp.net、jQuery和CSS制作了一个幻灯片。我有一切工作非常好,但我想在我的网页中心。不管我做什么,我都会得到一个奇怪的结果 每当我尝试执行Javascript jQuery幻灯片放映未居中,javascript,jquery,html,asp.net,Javascript,Jquery,Html,Asp.net,我用HTML/asp.net、jQuery和CSS制作了一个幻灯片。我有一切工作非常好,但我想在我的网页中心。不管我做什么,我都会得到一个奇怪的结果 每当我尝试执行marginleft:auto和marginright:auto时,什么都不会发生。它停留在页面的左侧。当我尝试执行文本对齐:居中时,我也看不到任何更改 以下是我的全部代码: HTML/asp.net: <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site
marginleft:auto
和marginright:auto
时,什么都不会发生。它停留在页面的左侧。当我尝试执行文本对齐:居中
时,我也看不到任何更改
以下是我的全部代码:
HTML/asp.net:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="mypage._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<link href="/Styles/Home.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div id="slideshow">
<img src="Images/me.jpg" alt="" class="active" height="500" width="700"/>
<img src="Images/WaterfallPic.JPG" alt="" height="500" width="700"/>
</div>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="Scripts/HomeSlideshow.js">
slideSwitch();
</script>
</asp:Content>
CSS:
在css中,#幻灯片是相对定位的。在本例中,它是相对于左上角的。利润率不会影响它
取出相对位置,或者在div元素的css中添加“position:static”
<div id="slideshow" style='position:static'>
当我这样做时,它会进一步向上移动到左上角,甚至与母版页重叠。现在将页边距添加回主页面。同样奇怪的是,如果我将其保留为position:relative
并将页边距设置为auto,它会移动到网页的右侧(大约200像素的填充)。所以它偏右了。。。
#slideshow {
position:relative;
height:350px;
width: 350px;
text-align: center;
}
#slideshow IMG {
position:absolute;
top:0;
left:3px;
z-index:8;
float: none;
}
#slideshow IMG.active {
z-index:10;
}
#slideshow IMG.last-active {
z-index:9;
}
<div id="slideshow" style='position:static'>