Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 09.08.2011, 13:14
Новичок на форуме
Отправить личное сообщение для aleha Посмотреть профиль Найти все сообщения от aleha
 
Регистрация: 25.03.2011
Сообщений: 8

ie8 ie9 display:none troubles
Имеется порядка 90 изображений расположенных inline, т.е. одна за другой, чтобы по достижении границы контейнера перескакивали на новую строку. Имеется механизм фильтрации, на jQuery и аналогичный на javaScript, который по определенным условиям проставляет некоторым картинкам dispaly:none а другим соответственно display:inline. В лисе всё отображается как и ожидается. В IE большая часть display:none прячется, но при этом остается несколько дырок, как будто был применен метод visibility:hidden.
В чем может быть загвоздка?
Ответить с цитированием
  #2 (permalink)  
Старый 09.08.2011, 13:19
что-то знаю
Отправить личное сообщение для devote Посмотреть профиль Найти все сообщения от devote
 
Регистрация: 24.05.2009
Сообщений: 5,176

у картинок имеется margin, padding, border или размеры у картинок не идентичны... что бы переносилось на другую строку, нужно что бы высота у картинок была одинаковая.
Ответить с цитированием
  #3 (permalink)  
Старый 09.08.2011, 14:09
Новичок на форуме
Отправить личное сообщение для aleha Посмотреть профиль Найти все сообщения от aleha
 
Регистрация: 25.03.2011
Сообщений: 8

Сообщение от devote Посмотреть сообщение
у картинок имеется margin, padding, border или размеры у картинок не идентичны... что бы переносилось на другую строку, нужно что бы высота у картинок была одинаковая.
Картинки нормально переносятся на другую строку. Просто по середине ряда например образуется пустое место.
у картинок есть css класс, в котором им прописано, чтобы у всех была одинаковая высота.
при простановке 0 нулевых margin и padding ничего не меняется
Ответить с цитированием
  #4 (permalink)  
Старый 09.08.2011, 16:48
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,123

Сообщение от aleha
В чем может быть загвоздка?
Пример чёле какой сделай...
Ответить с цитированием
  #5 (permalink)  
Старый 09.08.2011, 17:13
Новичок на форуме
Отправить личное сообщение для aleha Посмотреть профиль Найти все сообщения от aleha
 
Регистрация: 25.03.2011
Сообщений: 8

Сообщение от ksa Посмотреть сообщение
Пример чёле какой сделай...
выдергиваю разметку из рабочей версии.
Так выглядит кусок где расположены картинки. Одна за другой.
...
<td style="text-align:center;padding:0 20 0 20;" id="image_list">
    <img class="imgStyle "alt="costType3 cigType0" src="images/Prestige_KS/Competitors/DAVIDOFF_REGULAR_(2).png" onclick="nav('Prestige_KS')"/>
    <img class="imgStyle" alt="costType3 cigType0" src="images/Prestige_KS/Competitors/KENT_REGULAR.png" onclick="nav('Prestige_KS')"/>
    <img class="imgStyle" alt= "costType3 cigType0" src="images/Prestige_KS/Competitors/KENT_SURROUND.png" onclick="nav('Prestige_KS')"/>
    <img class="imgStyle" alt="costType3 cigType0" src="images/Prestige_KS/Competitors/MARLBORO_PLUS.png" onclick="nav('Prestige_KS')"/>
    <img class="imgStyle" alt= "costType3 cigType0" src="images/Prestige_KS/Competitors/PARLIAMENT_REGULAR.png" onclick="nav('Prestige_KS')"/>
...


Так выглядит кусок логики фильтрации:
var imgListTD = document.getElementById("image_list");
        var images = imgListTD.getElementsByTagName("img");

        for (var i = 0; i < images.length; i++) {

             var altText = images[i].getAttribute('alt');
             if (globalCost != undefined & globalCigType == undefined) {
                  if (altText.indexOf(globalCost) != -1) {
                      images[i].style.display = 'inline';
                      totalVisible++;
                  }
                  else {
                      images[i].style.display = 'none';
                  }
             }
        }

Вот результат который получается в ИЕ


Вот как в лисе
Ответить с цитированием
  #6 (permalink)  
Старый 09.08.2011, 18:27
что-то знаю
Отправить личное сообщение для devote Посмотреть профиль Найти все сообщения от devote
 
Регистрация: 24.05.2009
Сообщений: 5,176

хех, интересно получается)
может так попробовать:
var imgListTD = document.getElementById("image_list");
        var images = imgListTD.getElementsByTagName("img");

        for (var i = 0; i < images.length; i++) {

             var altText = images[i].getAttribute('alt');
             if (globalCost != undefined & globalCigType == undefined) {
                  if (altText.indexOf(globalCost) != -1) {
                      images[i].style.display = 'block';
                      images[i].style.float = 'left';
                      totalVisible++;
                  }
                  else {
                      images[i].style.display = 'none';
                  }
             }
        }


ну и в css у всех имагесов прописать:
.imgStyle {
....
display: block;
float: left;
....
}
Ответить с цитированием
  #7 (permalink)  
Старый 09.08.2011, 18:59
Новичок на форуме
Отправить личное сообщение для aleha Посмотреть профиль Найти все сообщения от aleha
 
Регистрация: 25.03.2011
Сообщений: 8

да так они все встали без разрывов, но при этом произошло выравнивание по левому краю, что не очень приятно. Теперь как их выровнять по центру?
Ответить с цитированием
  #8 (permalink)  
Старый 10.08.2011, 09:52
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,123

Сообщение от aleha
выдергиваю разметку из рабочей версии.
Пример нужно сделать такой, чтобы мы могли его запустить у себя. Огрызки мало что дадут...
Ответить с цитированием
  #9 (permalink)  
Старый 10.08.2011, 11:57
Новичок на форуме
Отправить личное сообщение для aleha Посмотреть профиль Найти все сообщения от aleha
 
Регистрация: 25.03.2011
Сообщений: 8

не проблема.
Вот пример. Открывать соответственно в IE. Взять какую-нибудь картинку, можно и без неё. Кликая на кнопочки фильтруется, но остаются дырки. Если делать display:block и float:left то образуется выравнивание по левому краю, что не годится к сожалению, так как нужно чтобы было по центру.


<html>
<head>
<style type="text/css">
.imgStyle
{
height:60px;

}
</style>

<script type="text/javascript">
function filter(costType) {
var globalCost = costType;
var imgListTD = document.getElementById("image_list");
var images = imgListTD.getElementsByTagName("img");

for (var i = 0; i < images.length; i++) {

var altText = images[i].getAttribute('alt');
if (globalCost != undefined) {
if (altText.indexOf(globalCost) != -1) {
images[i].style.display = 'inline';

totalVisible++;
}
else {
images[i].style.display = 'none';
}
}
}
}
</script>
</head>
<body>
<table style="width:500px;" border="1">
<tr>
<td id="image_list" style="text-align:center">
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType3 cigType0" src="CHESTERFIELD.png" />

<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType2 cigType0" src="CHESTERFIELD.png" />

<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType1 cigType0" src="CHESTERFIELD.png" />

<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />
<img class="imgStyle "alt="costType0 cigType0" src="CHESTERFIELD.png" />

</td>
</tr>
</table>
<input type="button" value="costType0" onClick="filter('costType0')"/>
<input type="button" value="costType1" onClick="filter('costType1')"/>
<input type="button" value="costType2" onClick="filter('costType2')"/>
<input type="button" value="costType3" onClick="filter('costType3')"/>

</body>

</html>
Ответить с цитированием
  #10 (permalink)  
Старый 10.08.2011, 13:26
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,123

aleha, это всё пробелы виноваты...
Вот вообще без дырок

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}
img {
	border: 0;
}
.imgStyle {
	height:60px;
}
</style>

<script type="text/javascript">
function filter(costType) {
var globalCost = costType;
var imgListTD = document.getElementById("image_list");
var images = imgListTD.getElementsByTagName("img");

for (var i = 0; i < images.length; i++) {

var altText = images[i].getAttribute('alt');
if (globalCost != undefined) {
if (altText.indexOf(globalCost) != -1) {
images[i].style.display = 'inline';

totalVisible++;
}
else {
images[i].style.display = 'none';
}
}
}
}
</script>
</head>
<body>
 <table style="width:500px;" border="1">
 <tr>
 <td id="image_list" style="text-align:center">
 <img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType3 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType2 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType1 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" /><img class="imgStyle "alt="costType0 cigType0" src="item1_1.jpg" />
 </td>
 </tr>
 </table>
 <input type="button" value="costType0" onClick="filter('costType0')"/>
 <input type="button" value="costType1" onClick="filter('costType1')"/>
 <input type="button" value="costType2" onClick="filter('costType2')"/>
 <input type="button" value="costType3" onClick="filter('costType3')"/>
</body>
</html>
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
window.resizeTo(w,h) в ie8 задёт не те размеры. mister_maxim Internet Explorer 1 29.07.2011 22:51
Как отключить режим совместимости в IE8? kidar2 Internet Explorer 2 25.06.2011 16:45
<= IE8 memory leak, IE9 - fine AbNormy Internet Explorer 1 20.05.2011 19:47
Глюк с background-position-y в ie8 DeMETAL Internet Explorer 3 14.01.2011 17:58
Как обработать изменение масштаба окна в IE8 ? v_k Events/DOM/Window 1 09.08.2010 13:35