/    Sign up×
Community /Pin to ProfileBookmark

Sticky-Glitchy MouseOver Issue

New member.

**Issue**: The code below is a sample of a section I am working on for a COVID theme website exercise. The issue with the code is that the MouseOver is sticky-glitchy, meaning that when I mouseover it is not responding as it should – it sometimes stays in its natural state or it bounces in and out or responses as it should when you pass the cursor over the target areas.

**Question**: Could someone help me identify where I am failing here?

[code]<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Sticky-Glitchy MouseOver Issue</title>

<style>
* {
box-sizing: border-box;
}

body {
background-color: #f1f1f1;
}

h1, h2, h3, h4, h5, h6, p {
text-align: center;
font-family: “Raleway”;
}
.top {
padding: 10px;
text-align: center;
background-color: #f1f1f1;
color: black;
font-size: 20px;
font-family: “Raleway”;
display: block
}
.quiz {
border-radius: 8px;
margin: 9px;
float: left;
width: 24%;
padding: 15px;
height: 250px;
background-color: #f9f9f9;
display: inline-block;
text-align: center;
font-family: “Libre+Baskerville”;
font-size: 20px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.buttonrow {
float: left;
width: 25%;
padding: 10px;
height: auto;
background-color: #f1f1f1;
display: inline-block
}
.row {
column-gap: 20px;
}
.row:after {
content: “”;
display: table;
clear: both;
}
.button {
position: relative;
font-family: “Raleway”;
font-weight: bold;
background-color: #000;
border-radius: 5px;
border: none;
color: white;
padding: 12px 28px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
transition-duration: 0.4s;
}
.button1:hover {
box-shadow: 0 10px 14px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
</style>

</head>
<body>

<div class=”top”>
<h2>Quiz</h2>
</div>
<div class=”row”>
<div class=”quiz”>
<div onmouseover=”qone_Over(this)” onmouseout=”qone_Out(this)”><strong>Question One</strong> <br><br> The Spanish Flu was a Pandemic.<br><br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer</div>
</div>
<div class=”quiz”>
<div onmouseover=”qtwo_Over(this)” onmouseout=”qtwo_Out(this)”><strong>Question Two</strong> <br><br> The term – A Slippery Slope – is a general fallacy of logic that plays no role in Denialism.<br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer</div>
</div>
<div class=”quiz”>
<div onmouseover=”qthree_Over(this)” onmouseout=”qthree_Out(this)”><strong>Question Three</strong> <br><br> COVID19 is the 19th version of the Coronavirus Disease.<br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer</div>
</div>
<div class=”quiz”>
<div onmouseover=”qfour_Over(this)” onmouseout=”qfour_Out(this)”><strong>Question Four</strong> <br><br> Washing your hands thoroughly for 20 to 30 seconds with regular soap, helps slow the spread of COVID. <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer</div>
</div>
</div>
<div class=”row”>
<div class=”buttonrow”>
<h2><a href=”” class=”button”>Read More</a></h2>
</div>
<div class=”buttonrow”>
<h2><a href=”” class=”button”>Read More</a></h2>
</div>
<div class=”buttonrow”>
<h2><a href=”” class=”button”>Read More</a></h2>
</div>
<div class=”buttonrow”>
<h2><a href=”” class=”button”>Read More</a></h2>
</div>
</div>

<script>
// MouseOver Message One Show
function qone_Over(obj_ov1) {
obj_ov1.innerHTML = “<strong>True</strong> – <i>The Spanish flu pandemic of 1918, the deadliest in history, infected an estimated 500 million people worldwide—about one-third of the planet’s population—and killed an estimated 20 million to 50 million victims, including some 675,000 Americans.</i>”
}
// MouseOver Message One Hide
function qone_Out(obj_ot1) {
obj_ot1.innerHTML = “<strong>Question One</strong> <br><br> The Spanish Flu was a Pandemic.<br><br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer”
}
// MouseOver Message Two Show
function qtwo_Over(obj_ov2) {
obj_ov2.innerHTML = “<strong>False</strong> – <i>Denialism employs five basic approaches: conspiracy, selectivity (cherry-picking), fake experts, impossible expectations, and general fallacies of logic.</i>”
}
// MouseOver Message Two Hide
function qtwo_Out(obj_ot2) {
obj_ot2.innerHTML = “<strong>Question Two</strong> <br><br> The term – A Slippery Slope – is a general fallacy of logic that plays no role in Denialism.<br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer”
}
// MouseOver Message Three Show
function qthree_Over(obj_ov3) {
obj_ov3.innerHTML = “<strong>False</strong> – <i>COVID19 means that this string of the Coranvirus Disease emerged or was discovered in the year 2019.</i>”
}
// MouseOver Message Three Hide
function qthree_Out(obj_ot3) {
obj_ot3.innerHTML = “<strong>Question Three</strong> <br><br> COVID19 is the 19th version of the Coronavirus Disease.<br> <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer”
}
// MouseOver Message Four Show
function qfour_Over(obj_ov4) {
obj_ov4.innerHTML = “<strong>True</strong> – <i>Hygiene, regardless of pandemics-epidemics and what not – having good hygiene practice is an essential part of maintaining a healthy lifestyle and killing off illness causing bacteria reducing the risk for diseases.</i>”
}
// MouseOver Message Four Hide
function qfour_Out(obj_ot4) {
obj_ot4.innerHTML = “<strong>Question Four</strong> <br><br> Washing your hands thoroughly for 20 to 30 seconds with regular soap, helps slow the spread of COVID. <br><br> <strong>True or False?</strong> <br><br> Mouse Over – To Reveal The Answer”
}
</script>

</body>
</html>[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumSep 20.2020 — This will work better when you apply the hover to the parent container div.quiz

Hover can be easily realised by CSS.

Your HTML (<i> tag and float) is outdated. float is the reason for the content overflowing the container when it's size is too small. Make youself familiar with flex layout instead, it will help you to achieve a responsive layout:

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

I adjusted the first QA:
&lt;div class="quiz"&gt;
&lt;div class="question"&gt;
&lt;h3&gt;Question One&lt;/h3&gt;
&lt;p&gt;The
Spanish Flu was a Pandemic.
&lt;/p&gt;
&lt;strong&gt;True or False?&lt;/strong&gt;
&lt;p&gt; Mouse Over - To
Reveal The Answer
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="answer"&gt;
&lt;strong&gt;True&lt;/strong&gt; - &lt;span class="italic"&gt;The Spanish flu pandemic of 1918, the deadliest in history,
infected an
estimated 500 million
people worldwide—about one-third of the planet's population—and killed an estimated 20 million to 50
million
victims, including some 675,000 Americans.&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="quiz"&gt;
&lt;!-- and so on --&gt;

CSS:
div.answer {
display: none;
}

<i> </i> div.quiz:hover div.question {
<i> </i> display: none;
<i> </i> }

<i> </i> div.quiz:hover div.answer {
<i> </i> display: block;
<i> </i> }

No javascript required.

You better use code tags instead of backtics: `your code here`

I edited your posting accordingly.
Copy linkTweet thisAlerts:
@cootheadSep 20.2020 — Hi there Furthark,

and a warm welcome to these forums. ;)

As @Sempervivum has pointed out no

[i]JavaScript[/i] is needed.

Here is another possible solution that

takes responsiveness into consideration...

<i>
</i>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;meta charset="utf-8"&gt;
&lt;meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"&gt;

&lt;title&gt;Sticky-Glitchy MouseOver Issue&lt;/title&gt;

&lt;link href="https://fonts.googleapis.com/css2?family=Libre+Baskerville&amp;family=Raleway&amp;display=swap" rel="stylesheet" media="screen"&gt;
&lt;style&gt;
html {
box-sizing: border-box;
}

*, *::before, *::after {
box-sizing: inherit;
}

body {
background-color: #f1f1f1;
}

h1, h2, h3, h4, h5, h6 {
font-family: Raleway, sans-serif;
text-align: center;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.5em;
}
#row {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
margin-bottom: 1em ;
}
.quiz {
position: relative;
width: 24%;
margin-bottom: 1em;
border-radius: 0.5em;
background-color: #f9f9f9;
font-family: 'Libre Baskerville', serif;
font-size: 1em;
text-align: center;
box-shadow: inset 0 0 1em rgba( 0, 0, 0, 0.3 ),
0 0.5em 1.25em 0 rgba( 0, 0, 0, 0.19);
overflow: hidden;
cursor: pointer;
}
.quiz &gt; div {
display: flex;
width: 200%;
margin-bottom: 2.5em;
transition: 0.5s ease-in-out;
}
.quiz:hover &gt; div {
margin-left:-100%;
}
.quiz &gt; div div {
width: 100%;
padding: 1em;
text-align: left;
}
.quiz a {
position: absolute;
left: 50% ;
bottom: 0;
transform: translate(-50% ,-50% );
padding: 0.7em 1.7em;
border-radius: 0.3em;
background-color: #000;
font-family: Raleway, sans-serif;
font-size: 0.8em;
font-weight: bold;
color: #fff;
text-align: center;
text-decoration: none;
white-space: nowrap;
transition: 0.4s ease-in-out;
}
.quiz a:hover {
box-shadow: 0 0.6em 0.8em 0 rgba( 0,0,0,0.24 ),
0 1em 3em 0 rgba( 0,0,0,0.19 );
}
@media ( max-width: 50em ) {
.quiz {
width: 48%;
}
}
@media ( max-width: 30em ) {
.quiz {
width: 98%;
}
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;Quiz&lt;/h1&gt;

&lt;div id="row"&gt;
&lt;div class="quiz"&gt;
&lt;div&gt;
&lt;div&gt;
&lt;h2&gt;Question One&lt;/h2&gt;
&lt;p&gt;The Spanish Flu was a Pandemic.&lt;/p&gt;
&lt;h2&gt;True or False?&lt;/h2&gt;
Mouse Over - To Reveal The Answer
&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;True&lt;/h2&gt;
&lt;i&gt;
The Spanish flu pandemic of 1918, the deadliest in history, infected an estimated 500 million
people worldwide - about one-third of the planet's population - and killed an estimated 20
million to 50 million victims, including some 675,000 Americans.
&lt;/i&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="#"&gt;Read More&lt;/a&gt;
&lt;!-- .quiz --&gt;&lt;/div&gt;

&lt;div class="quiz"&gt;
&lt;div&gt;
&lt;div&gt;
&lt;h2&gt;Question Two&lt;/h2&gt;
&lt;p&gt;The term - A Slippery Slope - is a general fallacy of logic that plays no role in Denialism.&lt;/p&gt;
&lt;h2&gt;True or False?&lt;/h2&gt;
Mouse Over - To Reveal The Answer
&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;False&lt;/h2&gt;
&lt;i&gt;
Denialism employs five basic approaches: conspiracy, selectivity (cherry-picking), fake experts,
impossible expectations, and general fallacies of logic.
&lt;/i&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="#"&gt;Read More&lt;/a&gt;
&lt;!-- .quiz --&gt;&lt;/div&gt;

&lt;div class="quiz"&gt;
&lt;div&gt;
&lt;div&gt;
&lt;h2&gt;Question Three&lt;/h2&gt;
&lt;p&gt;COVID19 is the 19th version of the Coronavirus Disease.&lt;/p&gt;
&lt;h2&gt;True or False?&lt;/h2&gt;
Mouse Over - To Reveal The Answer
&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;False&lt;/h2&gt;
&lt;i&gt;COVID19 means that this string of the Coronavirus Disease emerged or was discovered in the year 2019.&lt;/i&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="#"&gt;Read More&lt;/a&gt;
&lt;!-- .quiz --&gt;&lt;/div&gt;

&lt;div class="quiz"&gt;
&lt;div&gt;
&lt;div&gt;
&lt;h2&gt;Question Four&lt;/h2&gt;
&lt;p&gt;Washing your hands thoroughly for 20 to 30 seconds with regular soap, helps slow the spread of COVID.&lt;/p&gt;
&lt;h2&gt;True or False?&lt;/h2&gt;
Mouse Over - To Reveal The Answer
&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;True&lt;/h2&gt;
&lt;i&gt;
Hygiene, regardless of pandemics-epidemics and what not - having good hygiene practice is an essential part
of maintaining a healthy lifestyle and killing off illness causing bacteria reducing the risk for diseases.
&lt;/i&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="#"&gt;Read More&lt;/a&gt;
&lt;!-- .quiz --&gt;&lt;/div&gt;
&lt;!-- .row --&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;


[i]coothead[/i]
×

Success!

Help @Furthark spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...