Jump to content
  • 0

Как сделать динамическое изменение ширины?


PND
 Share

Question

Привет, искал что-то подобное, но не смог ничего найти.

Суть такая, есть таблицы. Надо их выровнять по левому краю. Ограничить в 1000пх. И суть в том, что надо что бы при добовлении новых таблиц в диве, они не переходили в следующую строчку, а оставались в нынешней и просто появлялась полоса прокрутки.

Вот сделал небольшой пример как это должно выглядеть. Тык.

Надо что бы когда эти блоки умещаются в 1000рх, то просто выравнивались по левому краю ( float:left типа ),а когда выходят за рамки, то появлялась полоса прокрутки. Как overflow:auto; но главное что бы оставались в 1 строчку. С фотками и текстом я такого эффекта добивался так:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#rr { overflow:auto; background:#330033; width:1000px;}
-->
</style>
</head>

<body>


<table width="200" border="1">
<tr>
<td nowrap="nowrap">
<div id="rr">

<img src="x_be5bc471.jpg" />
<img src="x_be5bc471.jpg" />
<img src="x_be5bc471.jpg" />
<img src="x_be5bc471.jpg" />
<img src="x_be5bc471.jpg" />
<img src="x_be5bc471.jpg" />

</div>
</td>
</tr>
</table>




</body>
</html>

А с таблицами и дивами не выходит. Если использовать ячейку таблицы с nowrap="nowrap" , то весь текст будет в строчку, а в блоке он должен быть в столбик. Надеюсь понятно объяснил. Прошу помочь.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Попробовал, кое что добавил и стало работать как надо :) , но только в опере. В ИЕ6 всё выстраивается просто в столбик. Можно как-нибуть повторить этот эффект для ИЕ6? / ие игнорирует white-space: nowrap; / то есть в ИЕ таблицы не выстраиваются в строчку.

Вот код:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#rr { white-space: nowrap; overflow:auto; width:1000px; background: #CCCCCC; }
#rr table { display: inline-block; white-space: normal; }
-->
</style>
</head>

<body>

<div id="rr">

<table width="200" border="1" bgcolor="#FFFFFF">
<tr>
<td>
j tdy jtdy jtdy jdtyjdlk hkjnlk lnhn khkjn knkjner;j ne;rjkgn;n;en tnt;nrtk;jg nhekljrglerglebrglhberlberlhgbljer gljber luberig eyrbguyerugb erubgy ergr
</td>
</tr>
</table>

<table width="200" border="1">
<tr>
<td>
<p>rtj srtj srtj srtjsrgj sr</p>
</td>
</tr>
</table>

<table width="200" border="1" bgcolor="#FFFFFF">
<tr>
<td> </td>
</tr>
</table>

<table width="200" border="1">
<tr>
<td> </td>
</tr>
</table>

<table width="200" border="1" bgcolor="#FFFFFF">
<tr>
<td> </td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td> </td>
</tr>
</table>

<table width="200" border="1" bgcolor="#FFFFFF">
<tr>
<td> </td>
</tr>
</table>

<table width="200" border="1">
<tr>
<td> </td>
</tr>
</table>


</div>
</body>
</html>

Edited by PND
Link to comment
Share on other sites

  • 0

На, держи:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
.wrap {
overflow-x:scroll;
width:1000px;
float:left;
white-space:nowrap;
}
.wrap table {
display:inline;
background:#330033;
border:#CCCCCC;
border-collapse:collapse;
}
.wrap table td {
width:200px;
}
</style>
</head>
<body>
<div class="wrap">

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>

<table>
<tr>
<td><img src="img.jpg"></td>
</tr>
</table>
</div>
</body>
</html>

Ой..., поспешил, в осле не пашет... щас посмотрим в чем дело.

UPD: поправил, должно везде работать. :)

Edited by rus
Link to comment
Share on other sites

  • 0
Как вариант:

 <!--[if lte IE 7]>
<style type="text/css">

#rr { overflow-x:scroll;}
#rr table { display: inline; white-space: pre; }
#rr table td {white-space: normal;}

</style>
<![endif]-->

Без хаков см. выше, только в 6 осле не проверял не знаю будет работать.

Link to comment
Share on other sites

  • 0

Спасибо, я пришёл к такому варианту:

#rr {  white-space: nowrap; width:1000px; overflow-x:auto; }

html>body #rr table { display: inline-block; white-space: normal; }

#rr table { display:inline }

Вроде проверил и всё работает, если найду косяки, обращусь к вашем rus, shvv вариантам. Спасибо. =)

Edited by PND
Link to comment
Share on other sites

  • 0
Спасибо, я пришёл к такому варианту:

#rr {  white-space: nowrap; width:1000px; overflow-x:auto; }

html>body #rr table { display: inline-block; white-space: normal; }

#rr table { display:inline }

Вроде проверил и всё работает, если найду косяки, обращусь к вашем rus, shvv вариантам. Спасибо. =)

У тебя тут очень много лишнего и совершенно ненужного... в общем как хочешь.

Edited by rus
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy