Why isn't the button border displaying the color I assigned to it?

After setting a border color to my button, it's not displaying the color when I click on it. Instead, it's showing a different color. How can I resolve this issue?

I need some assistance with setting the background of my button to match the image below (I'm unsure of what it's called).

The button I designed:

https://i.stack.imgur.com/Ua9FZ.jpg

The button design I'm aiming for:

https://i.stack.imgur.com/g6WXb.jpg

Additionally, why is the subheadline not staying on one line? It keeps moving to a new line.

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body, html {
    height: 100%;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 17px;
    color: #926239;
    line-height: 1.6;
}
.first-div {
    background: url(./pexels-miguel-á-padriñán-1591060.jpg);
    height: 100vh;
    width: 100%;
    background-attachment: scroll;
    background-position:center;
    background-repeat: no-repeat;
    background-size: cover;
}
.homepage-text {
    text-align: center;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.headline {
    color: #926239;
    font-size: 50px;
    line-height: 1.2;
}
.subheadline {
    color: #926239;
}
button {
    font-size: 18px;
    text-decoration: none;
    color: #926239;
    border: 1px solid #926239;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 20px;
}
button:hover {
    border: 1px solid #926239;
    background: #926239;
    color: white;
}
second-div {
    color: white;
    background: #926239;
    padding: 20px;
    text-align: center;
}
third-div {
    background: #f4f4f4;
    padding: 20px;
    text-align: center;
}
.section {
    display: flex;
    width: auto;
    height: auto;
    text-align: left;
}
box-01, .box-03 {
    padding: 20px;
    color: white;
    background: #926239;
}
.box-02 {
    padding: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    /* Repeat meta tags */
    <title>Project Name (Landing page)</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <div class="first-div">
            <div class="homepage-text">
                <h1 class="headline">Welcome Title Here</h1>
                <p class="subheadline">Place your subheadline here.</p>
            <button>Read More</button>
            </div>
        </div>
        <div class="second-div"><p>Content goes here.</p></div>
        <div class="third-div"><p>More content goes here.</p></div>
        <section class="section">
            <div class="box-01">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum dolorum est, molestias dolores sunt nobis temporibus veritatis odio!</p>
            </div>
            <div class="box-02">
                <p>Another Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum dolorum est, molestias dolores sunt nobis temporibus veritatis libero!</p>
            </div>
            <div class="box-03">
                <p>Even more content lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum dolorum est, molestias dolores quis nobis temporibus veritatis libero!</p>
            </div>
        </section>
    </div>
</body>
</html>

Answer №1

It seems like you're interested in this.

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body, html {
    height: 100%;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 17px;
    color: #926239;
    line-height: 1.6;
}
.first-div {
    background: url(./pexels-miguel-á-padriñán-1591060.jpg);
    height: 100vh;
    width: 100%;
    background-attachment: scroll;
    background-position:center;
    background-repeat: no-repeat;
    background-size: cover;
}
.homepage-text {
    text-align: center;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.headline {
    color: #926239;
    font-size: 50px;
    line-height: 1.2;
}
.subheadline {
    color: #926239;
    white-space: nowrap;
}
button {
    font-size: 18px;
    text-decoration: none;
    color: #926239;
    border: 1px solid #926239;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 20px;
    outline: none;
}
button:hover {
    border: 1px solid #926239;
    background: #926239;
    color: white;
}
.second-div {
    color: white;
    background: #926239;
    padding: 20px;
    text-align: center;
}
.third-div {
    background: #f4f4f4;
    padding: 20px;
    text-align: center;
}
.section {
    display: flex;
    width: auto;
    height: auto;
    text-align: left;
}
.box-01, .box-03 {
    padding: 20px;
    color: white;
    background: #926239;
}
.box-02 {
    padding: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project 07 (Landing page)</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <div class="first-div">
            <div class="homepage-text">
                <h1 class="headline">Welcome To The Beach</h1>
                <p class="subheadline">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.</p>
            <button>Read More</button>
            </div>
        </div>
        <div class="second-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit ab ipsam perspiciatis ut, provident perferendis sapiente in numquam blanditiis, enim, illo error nulla incidunt quos quidem ratione repellat ipsa molestias veritatis? Mollitia, fugit dolore commodi porro repudiandae atque, eos, ipsum quam culpa fuga deleniti quae.</p></div>
        <div class="third-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit ab ipsam perspiciatis ut, provident perferendis sapiente in numquam blanditiis, enim, illo error nulla incidunt quos quidem ratione repellat ipsa molestias veritatis? Mollitia, fugit dolore commodi porro repudiandae atque, eos, ipsum quam culpa fuga deleniti quae.</p></div>
        <section class="section">
            <div class="box-01">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-02">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-03">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
        </section>
    </div>
</body>
</html>

Answer №2

To achieve the desired button background effect, you should use background:transparent:

"I need assistance with setting the button background similar to the image below (I'm not sure what it's called)"

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body, html {
    height: 100%;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 17px;
    color: #926239;
    line-height: 1.6;
}
.first-div {
    background: url(https://img.freepik.com/free-vector/abstract-blue-geometric-shapes-background_1035-17545.jpg?size=626&ext=jpg);
    height: 100vh;
    width: 100%;
    background-attachment: scroll;
    background-position:center;
    background-repeat: no-repeat;
    background-size: cover;
}
.homepage-text {
    text-align: center;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.headline {
    color: #926239;
    font-size: 50px;
    line-height: 1.2;
}
.subheadline {
    color: #926239;
}
button {
    font-size: 18px;
    text-decoration: none;
    color: #926239;
    border: 1px solid #926239;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 20px;
    outline:none;
    background:transparent;
}
button:hover {
    border: 1px solid #926239;
    background: #926239;
    color: white;
}
.second-div {
    color: white;
    background: #926239;
    padding: 20px;
    text-align: center;
}
.third-div {
    background: #f4f4f4;
    padding: 20px;
    text-align: center;
}
.section {
    display: flex;
    width: auto;
    height: auto;
    text-align: left;
}
.box-01, .box-03 {
    padding: 20px;
    color: white;
    background: #926239;
}
.box-02 {
    padding: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project 07 (Landing page)</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <div class="first-div">
            <div class="homepage-text">
                <h1 class="headline">Welcome To The Beach</h1>
                <p class="subheadline">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            <button>Read More</button>
            </div>
        </div>
        <div class="second-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit</p></div>
        <div class="third-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit ab ipsam perspiciatis ut, provident perferendis sapiente in numquam blanditiis, enim, illo error nulla incidunt quos quidem ratione repellat ipsa molestias veritatis? Mollitia, fugit dolore commodi porro repudiandae atque, eos, ipsum quam culpa fuga deleniti quae.</p></div>
        <section class="section">
            <div class="box-01">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-02">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-03">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
        </section>
    </div>
</body>
</html>

Answer №3

Updates: MODIFY:

background-color: transparent;

WITHIN THE BUTTON IN CSS FILE

CSS:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body, html {
    height: 100%;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 17px;
    color: #926239;
    line-height: 1.6;
}
.first-div {
    background: url(./pexels-miguel-á-padriñán-1591060.jpg);
    height: 100vh;
    width: 100%;
    background-attachment: scroll;
    background-position:center;
    background-repeat: no-repeat;
    background-size: cover;
}
.homepage-text {
    text-align: center;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.headline {
    color: #926239;
    font-size: 50px;
    line-height: 1.2;
}
.subheadline {
    color: #926239;
}
button {
    font-size: 18px;
    text-decoration: none;
    color: #926239;
    background-color: transparent;
    border: 1px solid #926239;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 20px;
}
button:hover {
    border: 1px solid #926239;
    background: #926239;
    color: white;
}
.second-div {
    color: white;
    background: #926239;
    padding: 20px;
    text-align: center;
}
.third-div {
    background: #f4f4f4;
    padding: 20px;
    text-align: center;
}
.section {
    display: flex;
    width: auto;
    height: auto;
    text-align: left;
}
.box-01, .box-03 {
    padding: 20px;
    color: white;
    background: #926239;
}
.box-02 {
    padding: 20px;
}

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project 07 (Landing page)</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <div class="first-div">
            <div class="homepage-text">
                <h1 class="headline">Welcome To The Beach</h1>
                <p class="subheadline">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.</p>
            <button>Read More</button>
            </div>
        </div>
        <div class="second-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit ab ipsam perspiciatis ut, provident...</p></div>
        <div class="third-div"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore? Tempore reprehenderit ab ipsam perspiciatis ut, provident...</p></div>
        <section class="section">
            <div class="box-01">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-02">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
            <div class="box-03">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</p>
            </div>
        </section>
    </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

fontawesome issue: "One or more icons could not be located"

I utilized the instructions found on https://fontawesome.com/how-to-use/on-the-web/using-with/vuejs. However, when implementing it as follows: import { library } from '@fortawesome/fontawesome-svg-core' import { faBars } from '@fortawesome ...

Trouble with highlighting the chosen menu item

I have been attempting to implement this code snippet from JSFiddle onto my website. Although I directly copied the HTML, used the CSS inline, and placed the Javascript in an external file, the functionality does not seem to be working properly. Feel free ...

Creating your own unique CSS animation or transition timing function is a great way to add a

When it comes to CSS timing functions, they often appear to exist between two specific points: https://i.stack.imgur.com/qyvON.png Even with the option of using custom bezier curves, the curve created can only transition from one point to another. https ...

Tips for adjusting UI size in CSS based on viewport dimensions and accommodating image content

The elements E1, E2, E3, E4 are all part of the user interface (UI) and are intended to have a hover effect. Additionally, there is a background image included in the design. Currently, this is the progress made on the project: <div class="bg"> ...

How can we use a :before tag element to create a hovering effect on an image that remains clickable?

My objective is to create an image that is wrapped in a link. The link will have a pseudo element :before that adds a black overlay on hover. I want the image to remain clickable, but no matter what I try, the pseudo element won't position correctly o ...

Executing a function by click event using the onclick attribute from a file located in the public directory of my project (Next

I'm new to using Next.js and I have a question about how to utilize onclick to execute a function from an external file located in my public folder. Below is my index.js file: import Head from "next/head" import Script from "next/scrip ...

A pair of div elements within one section

Can you explain why the following HTML code uses two divs, one with a class and the other with an ID, instead of just using one of them to assign properties? .header { background-image: url("https://s3.amazonaws.com/codecademy-content/courses/web-101/ ...

Styling with ngStyle and changing the background image

Having an issue with a component that has an @Input string value linking to an image. In my HTML file, I originally had: <div class="parallax" [ngStyle]="{'background-image': 'url({{parallaxImage}})'}"></div> This was not ...

Place one flex item in the center and align another item to the bottom

I am attempting to center one flex item both vertically and horizontally. At the same time, I want some text to remain fixed at the bottom of the flex container. When I use margin-top:auto on the text, it just moves the inner box to the top. Any suggesti ...

The location layer on my Google Maps is not appearing

For a school project, I am working on developing a mobile-first website prototype that includes Google Maps integration. I have successfully added a ground overlay using this image, but I am facing issues with enabling the "my location layer". When I tried ...

Using Javascript to dynamically add form fields based on the selection made in a combo box

I am in the process of creating an information submission page for a website, where various fields will need to be dynamically generated based on the selection made in a combo box. For example, if the user selects "2" from the combo box, then two addition ...

Ways to retrieve a JSON element and incorporate it into a CSS styling

Can someone assist me in converting a JSON object for use in CSS? I've attempted to do this using Vue.js, creating a map legend with v-for to generate the legend. However, if there is an alternative method that allows me to take a JSON object and ins ...

Adjust the Material UI Select component to accommodate the length of the label

Is there a way to automatically adjust the size of Material-UI's Select input based on the label? In the official demo, minWidth is added to the formControl element. However, I have multiple inputs and do not want to set fixed sizes for each one. Whe ...

Having difficulties showcasing a variety of images stored in the database

I'm having some trouble with my e-commerce site. I can't seem to display different product images from the database on my homepage. The code I have only shows one image for all products, even though they should each have their own unique image up ...

interactive form fields updating using javascript

Hey there! I'm a beginner in web development and currently facing a challenge. I have a form with 2 fields generated by one drop-down menu. I've managed to generate one field, but struggling to get the other due to my limited knowledge. I just ne ...

The printed Bootstrap web page is being truncated

I have a unique dynamic webpage created with Bootstrap that needs to be printable. I am implementing media queries for styling the page when printing: /** Custom Print Styles **/ @media print { header, .menu, footer { display: none; ...

What is the process for adding text before and after a Bootstrap progress bar?

I want to customize the bootstrap progress bar with text at the beginning and end, like this: 5 star ----------------------------------------------- 70% Here is my attempt to achieve this: <link rel="stylesheet" href="https ...

Accordion styling using CSS

My current issue lies with setting the style for the contents of an accordion. The problem arises when the styles defined in a CSS file do not take effect on the content of my accordion when using the following code along with a separate CSS file: <scr ...

What are the steps to integrating databases with HTML5?

I currently have SPA applications developed with angularjs, but I am in need of creating an installer that allows users to work offline using a secure local database. I experimented with IndexedDB and converted my SPA into a Chrome extension, however, I di ...

HTML- Any suggestions on how to troubleshoot my sticky navbar not functioning properly?

I'm having trouble creating a sticky navbar. I've attempted to use z-index: 999 but it's not behaving as expected. * { margin: 0; padding: 0; } .navbar { display: flex; align-items: center; justify-items: center; position: ...