The CSS button fails to react when it is hovered over

After successfully implementing a button, I decided to add a new block div called 'dark-blueright' positioned below 'light-blue'.

/*
▒█▀▀▀█ ▀▀█▀▀ ▒█░░▒█ ▒█░░░ ▒█▀▀▀   ▒█▀▀█ ▒█▀▀▀ ▒█▀▀▀█ ▒█▀▀▀ ▀▀█▀▀ 
░▀▀▀▄▄ ░▒█░░ ▒█▄▄▄█ ▒█░░░ ▒█▀▀▀   ▒█▄▄▀ ▒█▀▀▀ ░▀▀▀▄▄ ▒█▀▀▀ ░▒█░░ 
▒█▄▄▄█ ░▒█░░ ░░▒█░░ ▒█▄▄█ ▒█▄▄▄   ▒█░▒█ ▒█▄▄▄ ▒█▄▄▄█ ▒█▄▄▄ ░▒█░░ 

*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

/*
▒█▀▀▀█ ▀▀█▀▀ ▒█░░▒█ ▒█░░░ ▒█▀▀▀   ▒█▀▀▀█ ▒█░▒█ ▒█▀▀▀ ▒█▀▀▀ ▀▀█▀▀ 
░▀▀▀▄▄ ░▒█░░ ▒█▄▄▄█ ▒█░░░ ▒█▀▀▀   ░▀▀▀▄▄ ▒█▀▀█ ▒█▀▀▀ ▒█▀▀▀ ░▒█░░ 
▒█▄▄▄█ ░▒█░░ ░░▒█░░ ▒█▄▄█ ▒█▄▄▄   ▒█▄▄▄█ ▒█░▒█ ▒█▄▄▄ ▒█▄▄▄ ░▒█░░ 
*/

@font-face {
font-family: headingf;
src: url(header-font.ttf);
}
@font-face {
font-family: mainf;
src: url(main-font.ttf);
}
@font-face {
font-family: iconf;
src: url(icon.ttf);
}
.background_colour {
background-color: #c6cdd1;
height: 1700px;
position: relative;
    left: 0px;
    top: 0px;
z-index: -2;
}
.iconsf {
font-family: iconf;
font-size: 40px;
text-indent: 40px;
float: left;
}
.light-blue {
width: 1000px;
height: 500px;
position: relative;
background-color: #68cef3;
}
.dark-blueright {
width: 1000px;
height: 1000px;
background-color: #00aae7;
position: absolute;
    left: 0px;
    top: 0px;
z-index: -1;

}
.header-text {
font-family: headingf;
font-size: 170px;
position: inherit;
text-align: center;
top: 80px;
color: #ffffff;
letter-spacing: 10px 
}
.welcome-text {
font-family: mainf;
font-size: 70px;
position: inherit;
text-align: center;
top: 60px;
color: #ffffff;
letter-spacing: 10px 
}
.button-style1 {
position: relative;
top: 220px;
left: 400px;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #00a9e7), color-stop(1, #00a9e7) );
background:-moz-linear-gradient( center top, #00a9e7 5%, #00a9e7 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00a9e7', endColorstr='#00a9e7');
background-color:#00a9e7;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:-20px;
border:1px solid #ffffff;
display:inline-block;
color:#ffffff;
font-family:mainf;
font-size:15px;
font-weight:bold;
font-style:normal;
height:80px;
line-height:80px;
width:200px;
text-decoration:none;
text-align:center;
}
.button-style1:hover {
opacity: 0.6;
}
.button-style1:active {
opacity: 1;
}
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div class="background_colour">
<div class="dark-blueright">
</div>
<div class="light-blue">
<div class="header-text">
Oh. Hello
</div>
<div class="welcome-text">
welcome
</div>
<a href="#" class="button-style1"><span class="iconsf">r</span>Goto art</a>
</div> 
</div>
</body>
</html>

I wanted to achieve a hover effect on the button to change its opacity, but my CSS positioning skills proved to be lacking and I struggled to find assistance through research.

Answer №1

There was an issue with the z-index in your CSS class .background_colour, but I have fixed it and now the hover effect is functioning properly.

/*
▒█▀▀▀█ ▀▀█▀▀ ▒█░░▒█ ▒█░░░ ▒█▀▀▀   ▒█▀▀█ ▒█▀▀▀ ▒█▀▀▀█ ▒█▀▀▀ ▀▀█▀▀ 
░▀▀▀▄▄ ░▒█░░ ▒█▄▄▄█ ▒█░░░ ▒█▀▀▀   ▒█▄▄▀ ▒█▀▀▀ ░▀▀▀▄▄ ▒█▀▀▀ ░▒█░░ 
▒█▄▄▄█ ░▒█░░ ░░▒█░░ ▒█▄▄█ ▒█▄▄▄   ▒█░▒█ ▒█▄▄▄ ▒█▄▄▄█ ▒█▄▄▄ ░▒█░░ 

*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

/*
▒█▀▀▀█ ▀▀█▀▀ ▒█░░▒█ ▒█░░░ ▒█▀▀▀   ▒█▀▀▀█ ▒█░▒█ ▒█▀▀▀ ▒█▀▀▀ ▀▀█▀▀ 
░▀▀▀▄▄ ░▒█░░ ▒█▄▄▄█ ▒█░░░ ▒█▀▀▀   ░▀▀▀▄▄ ▒█▀▀█ ▒█▀▀▀ ▒█▀▀▀ ░▒█░░ 
▒█▄▄▄█ ░▒█░░ ░░▒█░░ ▒█▄▄█ ▒█▄▄▄   ▒█▄▄▄█ ▒█░▒█ ▒█▄▄▄ ▒█▄▄▄ ░▒█░░ 
*/

@font-face {
font-family: headingf;
src: url(header-font.ttf);
}
@font-face {
font-family: mainf;
src: url(main-font.ttf);
}
@font-face {
font-family: iconf;
src: url(icon.ttf);
}
.background_colour {
background-color: #c6cdd1;
height: 1700px;
position: relative;
    left: 0px;
    top: 0px;
z-index: 0;
}
.iconsf {
font-family: iconf;
font-size: 40px;
text-indent: 40px;
float: left;
}
.light-blue {
width: 1000px;
height: 500px;
position: relative;
background-color: #68cef3;
}
.dark-blueright {
width: 1000px;
height: 1000px;
background-color: #00aae7;
position: absolute;
    left: 0px;
    top: 0px;
z-index: -1;

}
.header-text {
font-family: headingf;
font-size: 170px;
position: inherit;
text-align: center;
top: 80px;
color: #ffffff;
letter-spacing: 10px 
}
.welcome-text {
font-family: mainf;
font-size: 70px;
position: inherit;
text-align: center;
top: 60px;
color: #ffffff;
letter-spacing: 10px 
}
.button-style1 {
position: relative;
top: 220px;
left: 400px;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #00a9e7), color-stop(1, #00a9e7) );
background:-moz-linear-gradient( center top, #00a9e7 5%, #00a9e7 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00a9e7', endColorstr='#00a9e7');
background-color:#00a9e7;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:-20px;
border:1px solid #ffffff;
display:inline-block;
color:#ffffff;
font-family:mainf;
font-size:15px;
font-weight:bold;
font-style:normal;
height:80px;
line-height:80px;
width:200px;
text-decoration:none;
text-align:center;
}
.button-style1:hover {
opacity: 0.6;
}
.button-style1:active {
opacity: 1;
}
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div class="background_colour">
<div class="dark-blueright">
</div>
<div class="light-blue">
<div class="header-text">
Oh. Hello
</div>
<div class="welcome-text">
welcome
</div>
<a href="#" class="button-style1"><span class="iconsf">r</span>Goto art</a>
</div> 
</div>
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When CSS 3 checkbox value is toggled to "off", it returns as null

I am currently using a checkbox element with the following HTML: <div class="onoffswitch"> <input type="checkbox" name="showOnNavigation" class="onoffswitch-checkbox" id="showOnNavigation" checked> <label class="onoffswitch-label" f ...

What occurs when Click events are triggered on an <object> element?

I have set up a div, and inside that container, I embedded an SVG image using object (which I plan to manipulate later...). <div id="click-me"> some random Text <object data="some.svg" /> </div> Next, I added event listeners for t ...

Adding fewer components to your current Angular 5 project

I have a JS Fiddle showcasing a CSS chart. How can I integrate LESS into my current Angular 5 project to make use of this chart? Also, where should I place the JavaScript and references to the LESS file from this example within my Angular component? The li ...

`How can I relocate an IFRAME within a DIV?`

Users have the ability to freely edit HTML content, which is fine. However, I need to relocate all IFRAME elements into a DIV. I attempted the following code: $('#rolunk_content iframe').html ('<div>1' + $('#rolunk_content i ...

Form Style Components

I am currently using a form that contains material-ui components. Instead of relying on inline styles for the width property, I want to use css-in-js instead. I have previous experience with styled-components but there seems to be no form element available ...

Tips for utilizing the font-family style to span multiple columns

I recently discovered that you can set the background color across table columns using the <colgroup> tag. table { border: 2px solid; border-collapse: collapse; } td { border: 2px solid; } <ta ...

Handling image errors in jQuery for responsive design queries

Images on my website change based on the screen size using media queries. I am looking for a way to handle errors that may occur using jQuery. I want to display a text message if the image fails to load. Here is the code I have so far: <div class="con ...

attaching a specific column to the right side of the browser window

Hey there! I have a challenge for you. How can I create a table with 4 columns, but only display 3 of them at all times even when resizing the browser? The 4th column should remain hidden, but I still need to be able to scroll to it if needed. Essentially, ...

The Eclipse IDE is experiencing issues with the functionality of the JavaScript Number class

In my latest project, I decided to create a Dynamic Web Project using the Eclipse IDE 2019-12 along with Apache Tomcat 8.5.55 server. The main functionality of this project is that a user can input integers and receive their sum as an output. To ensure dat ...

Implementing hover effect triggered by keyboard input

Is there a way to create a hover effect on a div when a specific key is pressed on the keyboard using jQuery? <div id="d-up" class="button"></div> Appreciate any help with this! Thank you. ...

Can you explain the functionality of the NextSibling method?

I have a question about how the property NextSibling behaves when using the method getElementsByClassName(). Let me illustrate the issue with this code example: function Sibling() { var x = document.getElementsByClassName('firstClass')[0]; ...

Tips on customizing KendoUI-Dialog titlebar using CSS for a single component

I am struggling with styling the KENDO UI dialog in a unique way: Imagine I have a component named WatComponent. Inside this component, When the user clicks the "Forbidden" button, my goal is to make a warning styled dialog appear, with a yellow/orange ...

Adding an Image to an InfoWindow on Google Maps

Hey there! I'm attempting to insert an image into a Google Maps infoWindow. Here's my code snippet: var ContactUs = function () { return { //main function to initiate the module init: function () { var map; $(document). ...

How can you ensure that text in a container automatically moves to a new line and causes the container to expand downward if necessary, when

Are you searching for a way to make text inside a container wrap to a new line and have the container expand downwards if needed? Update <div class="modal hide fade" id="modalRemoveReserve" style="display:none;"> <div class="modal-header"&g ...

Does the webpack style loader load only application-specific CSS, or is it designed to handle all CSS files?

I am in the process of improving the modularity of my front-end design by delving into webpack. This tool provides a style loader, which enables you to import a css file and inject it into the document like this: require("style/url!file!./file.css"); // = ...

Discover the secrets to replicating the mesmerizing horizontal scrolling menu akin to the

What is the most effective way to create a horizontal menu similar to the innovative Google picture menu? Could someone kindly share their knowledge and provide the code for achieving the same outcome? ...

Finding out the specific row that was clicked in a Jquery Mobile listview

I've searched everywhere and can't find a solution. How can I retrieve the value of a row tapped in a listview? This could be anything from the name to the index within the object. Currently, I have a function handling the tap event. I need to pa ...

`Understanding Unique Identifiers in HTML: Questions on Element Naming`

Is it problematic to use a space character in an element ID? For example, like this: <li id='something with spaces'>Test123</li> I typically avoid using spaces in IDs, but I've encountered a situation where it might be necessar ...

Instructions for creating a distinct click listener for each <img> element inside a table cell

Within my table, each row contains multiple columns with images as data. I successfully implemented a 'common listener' that is triggered when any image within a table row is clicked. $('#mytable tbody td img').click(function () { // ...

Automatic button rotation

I managed to set up a button that works on click with a delay, making it semi-automatic. However, I'm struggling with getting it to not pause after just one click. Here's what I have so far: <!DOCTYPE html> <html> <body> &l ...