【发布时间】:2012-02-21 18:40:15
【问题描述】:
所以,我试图从顶部和左侧将这个 html 偏移 300 像素。到目前为止我尝试过的所有事情都没有奏效,但如果你知道一个可以帮助我的页面,我会非常有兴趣阅读它......我已经有了三个我想保留的框架在这里,我正在尝试使用“pagediv”创建偏移量,但没有骰子。
我盗用了框架布局(海盗的骄傲),因为我的 CSS 经验有限。再一次,我一直在摆弄它,试图让它在窗口左上角的右下方和右侧显示 300 像素。
但它不会让步!你会怎么做?请记住,我只能将 html 插入到主机的编辑器中——这很糟糕。我无法在服务器上管理自己的文件。哦!是的。理想情况下,我用来抵消的框架会很清晰——因为我放置这个 HTML 的地方已经有各种各样的菜单和疯狂的业务在左边和上面我不想掩盖.
<!--Force IE6 into quirks mode with this comment tag-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dynamic Drive: CSS Left and Right Frames Layout</title>
<style type="text/css">
body{
padding-top:200px;padding-left:200px;
padding: 0;
border: 0;
overflow: hidden;
height: 100%;
max-height: 100%;
}
#pagediv{
padding-top:300px;
padding-left:300px;
}
#framecontentLeft, #framecontentRight{
position: absolute;
top: 0;
left: 0;
width: 300px; /*Width of left frame div*/
height: 100%;
overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/
background-color: white;
color: black;
}
#framecontentRight{
left: auto;
right: 0;
width: 250px; /*Width of right frame div*/
overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/
background-color: white;
color: black;
}
#maincontent{
position: fixed;
top: 0;
left: 250px; /*Set left value to WidthOfLeftFrameDiv*/
right: 300px; /*Set right value to WidthOfRightFrameDiv*/
bottom: 0;
overflow: auto;
background: #fff;
}
innertube{
margin: 15px; /*Margins for inner DIV inside each DIV (to provide padding)*/
}
* html body{ /*IE6 hack*/
padding: 0 150px 0 200px; /*Set value to (0 WidthOfRightFrameDiv 0 WidthOfLeftFrameDiv)*/
}
* html #maincontent{ /*IE6 hack*/
height: 100%;
width: 100%;
}
</style>
<script type="text/javascript">
/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["This is a test page for a gym", "We wholly believe in the art of strength", "Ipso liptum facto freako."]
function filltext(words){
for (var i=0; i<words; i++)
document.write(gibberish[Math.floor(Math.random()*3)]+" ")
}
</script>
</head>
<body>
<Font face = "helvetica">
<div id = "pagediv">
<div class = "innertube">
<div id="framecontentLeft">
<div class="innertube">
<table width="100%" height="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td align="left" valign="top">
<h1>Videos</h1>
</td></tr>
<tr><td align="left" valign="top">
<img src="video sample.png" width="200" height="200" />
</td></tr>
<tr><td align="left" valign="top">
<img src="video sample.png" width="200" height="200" />
</td></tr>
<tr><td align="left" valign="top">
<img src="video sample.png" width="200" height="200" />
</td></tr>
</table>
</div>
</div>
<div id="framecontentRight">
<div class="innertube">
<table width="100%" height="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td align="left" valign="top"><h1><b> Location: </b></h1> <br />
<iframe width="200" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=2110+Pine+St.+Abilene,+TX+79601&aq=&sll=37.0625,-95.677068&sspn=77.57349,131.132813&ie=UTF8&hq=&hnear=2110+Pine+St,+Abilene,+Texas+79601&t=m&z=14&ll=32.473249,-99.731684&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q=2110+Pine+St.+Abilene,+TX+79601&aq=&sll=37.0625,-95.677068&sspn=77.57349,131.132813&ie=UTF8&hq=&hnear=2110+Pine+St,+Abilene,+Texas+79601&t=m&z=14&ll=32.473249,-99.731684" style="color:#0000FF;text-align:left">View Larger Map</a></small> <br />
Art of Strength Abilene @ Hendrick Heatlh Club <br />
2110 Pine St. Abilene, TX 79601 <br />
(325) 670-7682
</td></tr>
<tr><td align="left" valign="top">
<h1> Contact </h1>
Phone : 1 390 232 2323 <br />
Email : abeline@aos.com <br />
Website : Link
</td></tr>
<tr><td align="left" valign="top">
<img src="advertisement1.jpg" width="150" height="250" />
</td></tr>
<tr><td align="left" valign="top">
<img src="advertisement1.jpg" width="200" height="200" />
</td></tr>
<tr><td align="left" valign="top">
<img src="advertisement1.jpg" width="175" height="100" />
</td></tr>
</table>
<
</div>
</div>
<div id="maincontent">
<div class="innertube">
<table width="100%" height="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td align="left" valign="top">
<h1>About AOS Abeline, Texas </h1>
<p><script type="text/javascript">filltext(25)</script></p>
</td></tr>
<tr><td align="left" valign="top">
<h1>Our Training</h1>
<p><script type="text/javascript">filltext(300)</script></p>
<img src="../../Documents/punch/new aos site/Screen shot 2011-12-07 at 10.12.27 AM.png" width="307" height="243" />
</td></tr><tr><td align="left" valign="top">
<h1>Staff</h1>
<p><script type="text/javascript">filltext(10)</script></p>
</td></tr>
</table>
</div>
</div>
</div>
</div>
</FONT>
</body>
</html>
【问题讨论】:
-
你试过
body{padding-top:300px;padding-left:300px;}或body{margin-top:300px;margin-left:300px;}而不是零值吗? -
如果你的意思只是将它添加到 CSS 的正文部分,那么是的,我刚刚尝试过——第一个导致所有内容都向左对齐,摆脱了框架.第二个似乎没有影响任何东西......对不起。
-
在代码的底部,大约 175 行之后,有一个流浪的
<。此外,您有一个字体标签。不要使用字体标签,使用 CSS 应用字体。这不是你的定位问题——只是已经过时了。最后...你想要怪癖模式吗?这是我尽量避免的。 -
啊,超现实主义,感谢您提供的信息。我已经修复了 <. quirks css>
-
Quirks 模式是一种 IE 模式 - 这意味着它以自己的方式呈现事物,而不是标准方式。我总是试图远离它。 CSS 是用于改变页面外观的样式标记。我们的想法是使用 HTML 构建页面,并使用 CSS 使其看起来像您想要的那样。