Changing image on hover the text











up vote
-3
down vote

favorite












There are 4 texts. When I hover on each of them I can see a certain picture which belongs to certain text.



The question is that, I need a slider consist of images. I mean when I hover on text1 I need to see my image and after one second this image has to disappear.



So, I need to do it with all texts, but in my code I just can see one image, apart from it is not a slider. Can you help me in this question?



This is the code:






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>












share|improve this question




















  • 1




    Excuse me but what are p1 p2 p3 p4?
    – zmuci
    Nov 21 at 12:10






  • 1




    @zmuci these are paragraphs which equal to certain text
    – timur
    Nov 21 at 13:19












  • my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
    – zmuci
    Nov 22 at 10:26

















up vote
-3
down vote

favorite












There are 4 texts. When I hover on each of them I can see a certain picture which belongs to certain text.



The question is that, I need a slider consist of images. I mean when I hover on text1 I need to see my image and after one second this image has to disappear.



So, I need to do it with all texts, but in my code I just can see one image, apart from it is not a slider. Can you help me in this question?



This is the code:






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>












share|improve this question




















  • 1




    Excuse me but what are p1 p2 p3 p4?
    – zmuci
    Nov 21 at 12:10






  • 1




    @zmuci these are paragraphs which equal to certain text
    – timur
    Nov 21 at 13:19












  • my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
    – zmuci
    Nov 22 at 10:26















up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











There are 4 texts. When I hover on each of them I can see a certain picture which belongs to certain text.



The question is that, I need a slider consist of images. I mean when I hover on text1 I need to see my image and after one second this image has to disappear.



So, I need to do it with all texts, but in my code I just can see one image, apart from it is not a slider. Can you help me in this question?



This is the code:






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>












share|improve this question















There are 4 texts. When I hover on each of them I can see a certain picture which belongs to certain text.



The question is that, I need a slider consist of images. I mean when I hover on text1 I need to see my image and after one second this image has to disappear.



So, I need to do it with all texts, but in my code I just can see one image, apart from it is not a slider. Can you help me in this question?



This is the code:






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>








.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>





.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>
<div class="pic" style="border-radius: 20px;"></div>
<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>






javascript html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 11:37









Pete

40.1k1875116




40.1k1875116










asked Nov 21 at 11:26









timur

11




11








  • 1




    Excuse me but what are p1 p2 p3 p4?
    – zmuci
    Nov 21 at 12:10






  • 1




    @zmuci these are paragraphs which equal to certain text
    – timur
    Nov 21 at 13:19












  • my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
    – zmuci
    Nov 22 at 10:26
















  • 1




    Excuse me but what are p1 p2 p3 p4?
    – zmuci
    Nov 21 at 12:10






  • 1




    @zmuci these are paragraphs which equal to certain text
    – timur
    Nov 21 at 13:19












  • my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
    – zmuci
    Nov 22 at 10:26










1




1




Excuse me but what are p1 p2 p3 p4?
– zmuci
Nov 21 at 12:10




Excuse me but what are p1 p2 p3 p4?
– zmuci
Nov 21 at 12:10




1




1




@zmuci these are paragraphs which equal to certain text
– timur
Nov 21 at 13:19






@zmuci these are paragraphs which equal to certain text
– timur
Nov 21 at 13:19














my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
– zmuci
Nov 22 at 10:26






my point is that p1 .. p4 are not valid HTML tags. Unless you are using some sort of JS framework and these are custom components.
– zmuci
Nov 22 at 10:26














1 Answer
1






active

oldest

votes

















up vote
-2
down vote













This would not be like a slider but inside of pic div we can change images when Texts are hovered.
I assume that we have all the required images in folder img/src-img and img folder is in the same directory where the html page exists.



Below code is working fine in Chrome






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>








share|improve this answer























  • so what changes can you offer?
    – timur
    Nov 21 at 13:31










  • So what can you say about p1 , p2 , p3 and p4
    – Ramesh
    Nov 21 at 13:33










  • @timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
    – Anki
    Nov 22 at 4:47










  • @Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
    – Anki
    Nov 22 at 4:49










  • @Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
    – timur
    Nov 22 at 5:02













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411087%2fchanging-image-on-hover-the-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
-2
down vote













This would not be like a slider but inside of pic div we can change images when Texts are hovered.
I assume that we have all the required images in folder img/src-img and img folder is in the same directory where the html page exists.



Below code is working fine in Chrome






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>








share|improve this answer























  • so what changes can you offer?
    – timur
    Nov 21 at 13:31










  • So what can you say about p1 , p2 , p3 and p4
    – Ramesh
    Nov 21 at 13:33










  • @timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
    – Anki
    Nov 22 at 4:47










  • @Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
    – Anki
    Nov 22 at 4:49










  • @Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
    – timur
    Nov 22 at 5:02

















up vote
-2
down vote













This would not be like a slider but inside of pic div we can change images when Texts are hovered.
I assume that we have all the required images in folder img/src-img and img folder is in the same directory where the html page exists.



Below code is working fine in Chrome






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>








share|improve this answer























  • so what changes can you offer?
    – timur
    Nov 21 at 13:31










  • So what can you say about p1 , p2 , p3 and p4
    – Ramesh
    Nov 21 at 13:33










  • @timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
    – Anki
    Nov 22 at 4:47










  • @Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
    – Anki
    Nov 22 at 4:49










  • @Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
    – timur
    Nov 22 at 5:02















up vote
-2
down vote










up vote
-2
down vote









This would not be like a slider but inside of pic div we can change images when Texts are hovered.
I assume that we have all the required images in folder img/src-img and img folder is in the same directory where the html page exists.



Below code is working fine in Chrome






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>








share|improve this answer














This would not be like a slider but inside of pic div we can change images when Texts are hovered.
I assume that we have all the required images in folder img/src-img and img folder is in the same directory where the html page exists.



Below code is working fine in Chrome






.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>








.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>





.pic {
background-image: url(img/scr-img/1.png);
width: 236px;
height: 420px;
transition: 1s;
background-size: cover;
}

p1:hover~.pic {
background-image: url(img/scr-img/8.png);
}

p2:hover~.pic {
background-image: url(img/scr-img/9.png);
}

p3:hover~.pic {
background-image: url(img/scr-img/11.png);
}

p4:hover~.pic {
background-image: url(img/scr-img/5.png);
}

<p1 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text1</p>
</div>
</div>
</p1>
<p2 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text2</p><br><br><br>
</div>
</div>
</p2>

<p3 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center xs-mb50 xs-font wow fadeIn">
<p>Text3</p>
</div>
</div>
</p3>
<p4 style="cursor: pointer; font-size: 24px; color: #1A264A;">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4 col-sm-6 col-xs-12">
<div class="download-content sm-center xs-center wow fadeIn">
<p>Text4</p>
</div>
</div>
</p4>
<div class="pic" style="border-radius: 20px;"></div>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 at 12:32

























answered Nov 21 at 12:24









Anki

23718




23718












  • so what changes can you offer?
    – timur
    Nov 21 at 13:31










  • So what can you say about p1 , p2 , p3 and p4
    – Ramesh
    Nov 21 at 13:33










  • @timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
    – Anki
    Nov 22 at 4:47










  • @Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
    – Anki
    Nov 22 at 4:49










  • @Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
    – timur
    Nov 22 at 5:02




















  • so what changes can you offer?
    – timur
    Nov 21 at 13:31










  • So what can you say about p1 , p2 , p3 and p4
    – Ramesh
    Nov 21 at 13:33










  • @timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
    – Anki
    Nov 22 at 4:47










  • @Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
    – Anki
    Nov 22 at 4:49










  • @Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
    – timur
    Nov 22 at 5:02


















so what changes can you offer?
– timur
Nov 21 at 13:31




so what changes can you offer?
– timur
Nov 21 at 13:31












So what can you say about p1 , p2 , p3 and p4
– Ramesh
Nov 21 at 13:33




So what can you say about p1 , p2 , p3 and p4
– Ramesh
Nov 21 at 13:33












@timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
– Anki
Nov 22 at 4:47




@timur I just changed the position of pic div because for p1, p2 it was working fine. To get it worked for p3 and p4, pic div should be after p3 and p4 as well. Hope this answers your question.
– Anki
Nov 22 at 4:47












@Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
– Anki
Nov 22 at 4:49




@Ramesh, I cannot understand your question. Please elaborate what do exactly you want to ask?
– Anki
Nov 22 at 4:49












@Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
– timur
Nov 22 at 5:02






@Anki I want to create a slider of images. and when I hover on some text I need to see certain image and I need to do it with all texts
– timur
Nov 22 at 5:02




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411087%2fchanging-image-on-hover-the-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...