另一个CSS& Javascript问题 [英] Another CSS & Javascript Problem
问题描述
嘿,
当我使用下面的代码时,我试图根据访问者的
分辨率来调整img的大小。
图像调整大小很好,但桌子没有!继续使用原始图像的w / b
。
我试图将td {width = 60%}放在样式标记中,但这并没有帮助
要么。
如何解决这个问题???
thnx,
AT
< html>
< head>
< script language =" JavaScript"><! -
browser_version = parseInt(navigator.appVersion);
browser_type = navigator.appName;
if(window.screen.width ==" 1024" ;){
document.write("< style> img {width = 100%}< / style>");
}
else if(window.screen.width ==" 800"){
document.write("< style> img {width = 60%;}< / style> ;");
}
// - >< / script>
< / head>
< body>
< table>< tr>
< td>< img src =''im1.jpg''> < / a>< / td>
< td>< ; img src =''im2.jpg''>< / a>< td>
< / tr>
< / table>
Ang Talunin在comp.lang.javascript上写了10 okt 2003 :
嘿,
当我使用下面的代码时,我试图根据访问者的分辨率调整img的大小。
图像调整大小很好,但是桌子不是!这继续使用原始图像的
。
我试图将td {width = 60%}放在样式标签中,但这也没有帮助。
>如何解决这个问题???
thnx,
$
< html>
< head>
< script language =" JavaScript"><! -
browser_version = parseInt(navigator.appVersion);
browser_type = navigator.appName;
if(window.screen。 width ==" 1024"){
document.write("< style> img {width = 100%}< / style>");
}
if if (window.screen.width ==" 800"){
document.write("< style> img {width = 60%;}< / style>");
}
// - >< / script>
< / head>
< body>
< table>< tr>
< td>< img src =''im1.jpg''>< / a>< / td>
< td>< img src =''im2.jpg''>< / a>< td>
< / tr>
< / table>
1
宽度= 60%;
应该是
宽度:60%;
2
这不是原始img宽度的60%,而是td宽度的60%!
3 >
< / a>'在这里毫无意义。
4
最后一次< td>应该是< / td>
=========================
这将做你想做的事情:
< style>
table {width:100%;} / *跟随窗口宽度* /
td {width:50%;} / *跟随表格宽度* /
img {width:100%;} / *跟随td宽度* /
< / style>
< table>< tr>
< td>< img src =''im1.jpg''>< / td>
< td>< img src =''im2.jpg''>< / td>
< / tr>< / table>
未经测试。
-
Evertjan。
荷兰。
(请在我的电子邮件地址中将x'变为点数)
< BLOCKQUOTE>> < html>
< head>
< script language =" JavaScript"><! -
browser_version = parseInt(navigator.appVersion);
browser_type = navigator.appName;
if(window.screen.width ==" 1024"){
document.write("< style>如果(window.screen.width ==" 800"){
document.write(& ;< style> img {width = 60%;}< / style>");
}
// - >< / script>
< / head> ;
< body>
< table>< tr>
< td>< img src =''im1.jpg''>< / a>< / td>
< td>< img src =''im2.jpg''>< / a>< td>
< / tr>
< /表>
1
宽度= 60%;
应该是宽度:60%;
>
我试图改变第一个如果在::
if(window.screen.width ==" 1024"){
document.write("< style> table {width:100%} td {width:50%} img {
宽度:100%}< / style>");
}
但这不起作用......
其他任何想法?
Ang Talunin写道:
if(window.screen.width ==" 1024"){
如果(window.screen.width ==" 800"){
}
什么关于其他解决方案的人?
那些没有最大化浏览器窗口的人呢?
-
David Dorward http://dorward.me.uk/
Hey,
When I use the code beneath I''m trying to resize a img depending on the
resolution of the visitor.
The images resizes fine, but the table doesn''t! That keeps using the widht
of the original image.
I tried to put td { width=60%} in the style tag, but that didn''t help
either.
How to fix this???
thnx,
A.T.
<html>
<head>
<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;
if (window.screen.width == "1024") {
document.write("<style>img { width=100%}</style>");
}
else if (window.screen.width == "800") {
document.write("<style>img { width=60%;}</style>");
}
// --></script>
</head>
<body>
<table><tr>
<td><img src=''im1.jpg'' ></a></td>
<td><img src=''im2.jpg'' ></a><td>
</tr>
</table>
Ang Talunin wrote on 10 okt 2003 in comp.lang.javascript:
Hey,
When I use the code beneath I''m trying to resize a img depending on
the resolution of the visitor.
The images resizes fine, but the table doesn''t! That keeps using the
widht of the original image.
I tried to put td { width=60%} in the style tag, but that didn''t help
either.
How to fix this???
thnx,
A.T.
<html>
<head>
<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;
if (window.screen.width == "1024") {
document.write("<style>img { width=100%}</style>");
}
else if (window.screen.width == "800") {
document.write("<style>img { width=60%;}</style>");
}
// --></script>
</head>
<body>
<table><tr>
<td><img src=''im1.jpg'' ></a></td>
<td><img src=''im2.jpg'' ></a><td>
</tr>
</table>
1
width=60%;
should be
width:60%;
2
this is NOT 60% of the original img width, but 60% of the td width !
3
The </a>''s make no sense here.
4
The last <td> should be </td>
=========================
This will do what you probably want:
<style>
table {width:100%;} /* follows the window width */
td {width:50%;} /* follows the table width */
img {width:100%;} /* follows the td width */
</style>
<table><tr>
<td><img src=''im1.jpg''></td>
<td><img src=''im2.jpg''></td>
</tr></table>
not tested.
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
> <html><head>
<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;
if (window.screen.width == "1024") {
document.write("<style>img { width=100%}</style>");
}
else if (window.screen.width == "800") {
document.write("<style>img { width=60%;}</style>");
}
// --></script>
</head>
<body>
<table><tr>
<td><img src=''im1.jpg'' ></a></td>
<td><img src=''im2.jpg'' ></a><td>
</tr>
</table>
1
width=60%;
should be
width:60%;
I tried to change the first if in::
if (window.screen.width == "1024") {
document.write("<style>table{ width:100%} td{ width:50%} img{
width:100%}</style>");
}
But that doesn''t work....
any other ideas?
Ang Talunin wrote:
if (window.screen.width == "1024") {
else if (window.screen.width == "800") {
}
What about people with other resolutions?
What about people who don''t maximise their browser window?
--
David Dorward http://dorward.me.uk/
这篇关于另一个CSS& Javascript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!