Я нашел решение, которое я ищу на SoF, но проблема не устранена. Я, очевидно, ничего не делаю правильно. Возможно, еще одна пара глаз будет полезна.Показать DIV при наведении на другое DIV
В принципе, я хочу показать скрытый div, пока я навешиваю отдельный div. При наведении курсора на отдельный div он изменит цвет bg.
Спасибо за помощь.
Вот CodePen того, что у меня есть.
HTML
<div class="container-fluid">
<div class="image">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
<div class="five"></div>
</div>
<div class="one-text">
<p>Here is some text</p>
</div>
<div class="two-text">
<p>Here is some text</p>
</div>
<div class="three-text">
<p>Here is some text</p>
</div>
<div class="four-text">
<p>Here is some text</p>
</div>
<div class="five-text">
<p>Here is some text</p>
</div>
</div>
CSS
body {
background-color: #c5d5cb;
color: #fff;
font-family: Open Sans;
font-weight: 300;
margin: 0 auto;
}
.container-fluid {
background-color: #9fa8a3;
height: 600px;
padding: 30px;
}
.container-fluid .image {
background-color: #e3e0cf;
height: 100%;
width: 50%;
float: right;
padding: 30px;
display: flex;
justify-content: space-between;
}
.container-fluid .image .one {
background-color: #c5d5cb;
width: 100px;
height: 100px;
margin: 5px;
}
.container-fluid .image .one:hover {
background-color: #3b3a36;
}
.container-fluid .image .two {
background-color: #c5d5cb;
width: 100px;
height: 100px;
margin: 5px;
}
.container-fluid .image .two:hover {
background-color: #3b3a36;
}
.container-fluid .image .three {
background-color: #c5d5cb;
width: 100px;
height: 100px;
margin: 5px;
}
.container-fluid .image .three:hover {
background-color: #3b3a36;
}
.container-fluid .image .four {
background-color: #c5d5cb;
width: 100px;
height: 100px;
margin: 5px;
}
.container-fluid .image .four:hover {
background-color: #3b3a36;
}
.container-fluid .image .five {
background-color: #c5d5cb;
width: 100px;
height: 100px;
margin: 5px;
}
.container-fluid .image .five:hover {
background-color: #3b3a36;
}
.container-fluid .one-text {
width: 300px;
display: block;
float: right;
display: none;
}
.container-fluid .two-text {
width: 300px;
display: block;
float: right;
display: none;
}
.container-fluid .three-text {
width: 300px;
display: block;
float: right;
display: none;
}
.container-fluid .four-text {
width: 300px;
display: block;
float: right;
display: none;
}
.container-fluid .five-text {
width: 300px;
display: block;
float: right;
display: none;
}
.container-fluid .one:hover + .one-text {
display: block;
}
.container-fluid .two:hover + .two-text {
display: block;
}
.container-fluid .three:hover + .three-text {
display: block;
}
.container-fluid .four:hover + .four-text {
display: block;
}
.container-fluid .five:hover + .five-text {
display: block;
}
Проблемы заключается в том, что, например, '' .one' и .one-Text' не двойники элементов, следовательно, селектор «+» не будет работать в этом контексте. Возможное решение будет включать переупорядочение HTML или использование JavaScript/jQuery. Пожалуйста, сообщите, какие варианты вы готовы рассмотреть. –
Спасибо за ответ. Я понимаю что ты имеешь ввиду. Но, не могли бы вы сказать мне, почему, если я заменю .one: наведите указатель на .image: наведите указатель на строку 81, текст будет отображаться так, как я предполагал? Это из-за того, что .image и .one-text являются одновременно братьями и сестрами .container div? – dooge
быстрый, который зависал div, должен быть нацелен на какой div? Для этого есть некоторые уникальные правила, если все остальное не удается, JS wil do, скажите мне, какое действие вы хотите совершить –