The button background doesn't line up with the shadow on the vertical menu

I am currently working on a project that aims to investigate how older individuals interact with flat design compared to skeuomorphic design. As part of this study, I intend to create a 3D and realistic menu. While searching for a suitable pre-made button, I encountered an issue where attempting to orient the button vertically resulted in the shadow overflowing the parent element without affecting the background. The code snippet below illustrates the styling applied to the horizontal button:

HTML:

<a class="button">
    <span>TEXT FOR BUTTON</span>
</a>
<a class="button">
    <span>BUTTON 2</span>
</a>
<a class="button">
    <span>ANOTHER BUTTON</span>
</a>
<a class="button">
    <span>LAST BUTTON</span>
</a>

CSS:

.button {
    display: inline-block;
    margin: 5px;
    width: auto;

    -webkit-border-radius: 10px;
    -webkit-box-shadow: 
        /* Multiple layers of gradient effects */
    -webkit-transition: -webkit-box-shadow .1s ease-in-out;
} 

.button span {
    /* Styling for button text content */

    -webkit-border-radius: 10px;
    -webkit-transition: -webkit-transform .1s ease-in-out;
}

/* Additional styles for hover and active states are included */

The link provided shows the vertical alignment issue experienced when applying the same styles to a vertical button:

HTML:

<div class="container">
    <a class="button">
        <span>TEXT FOR BUTTON</span>
    </a>
    <a class="button">
        <span>BUTTON 2</span>
    </a>
    <a class="button">
        <span>ANOTHER BUTTON</span>
    </a>
    <a class="button">
        <span>LAST BUTTON</span>
    </a>
</div>

CSS:

.container {
    float: left;
    height: 100%;
    margin-right: 30px;
}
.button {
    /* Different styling properties from horizontal buttons */
} 

.button span {
    /* Similar to horizontal button span styles */

}

/* Hover, active state styles remain consistent */

If you can offer any insights or assistance in resolving this inconsistency between the two button orientations, it would be greatly appreciated!

Answer №1

If you're looking to adjust the button span's display, try changing it from inline-block to button span {display: block}. This will cause the button to fill up the surface uniformly. However, if you prefer varying widths for each button, switch the button itself to button {display: inline-block} and wrap each button in a div instead.

Consider adding more margin-bottom to the buttons for better spacing.

On another note, the provided code might seem a little complex and lacking in semantic structure. A simpler solution would involve applying the styling directly to a single <button></button>.

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

Adapting my desktop website layout to be responsive for an optimal viewing experience on iPads and mobile

I recently created a webpage for laptop view and attempted to use media queries to adjust the CSS styling to fit on iPad and mobile devices. However, when setting the width of the (.content) element to 100%, the content doesn't actually fill the entir ...

How can I make a Bootstrap video embed fill the entire width of the screen?

I'm struggling to integrate a YouTube video into my webpage with Bootstrap, but I want it to span the entire width of the page. Here's the HTML code: <iframe class="embed-responsive-item youtube" src="https://www.youtube.com/em ...

What factors dictate the color of rows in jquery datatable designs?

Within the jQuery datatable styles, such as "smoothness," the rows are displayed in different colors. What factors determine which colors are shown on each row? And is there a way to customize this color scheme? Refer to the example below from their sampl ...

The reset css code appears to be overridden by the user agent stylesheet

I've been developing a project using Next.js. I attempted to reset the CSS in my _app.tsx file and here is my _app.tsx code: import type { AppProps } from 'next/app' import GlobalStyles from '@/styles/GlobalStyles' export defa ...

Can you please provide instructions on how to expand the view in the title bar for a JavaScript/CSS/HTML UPW project?

Struggling to integrate the title bar in a UWP project using JavaScript/CSS/HTML and having trouble accessing the necessary APIs. Came across a custom helper class written in c++ in UWP samples on Github, but unable to reference it in my javascript code. H ...

Spin and Return: CSS Animation with Rotation

I am attempting to create an animation with this arrow that will move up and down, as well as rotate or change its direction at 0% and 100%. However, my current issue is that the arrow rotates for a second at 100% and then reverts back to its previous dire ...

Arrange JSON response data in alphabetical order

Looking to sharpen my skills by working with public APIs in JavaScript. My goal is to sort the list of items alphabetically by the h4 value (food name) when the query is submitted. I attempted to use .sort() on the response item before using .map(), but en ...

Tips on updating CSS styles for navigation bar links in real time

Currently, my homepage displays a CSS content hover effect when the user interacts with the icons. However, I am facing an issue where all icons show the same text "home" on hover. How can I customize the text output for each individual icon/link? Your hel ...

Bootstrap Modal for WooCommerce

I'm facing an issue while trying to create a modal window using woocommerce variables ($product). The problem lies in the placement of my modal and accessing the correct product id. Here is the code snippet I've been working on. Unfortunately, i ...

The design is not applied correctly to this table

After neglecting this aspect for a while in favor of focusing on the working part, I have now become more concerned about it and unfortunately, the issue persists. <table cellspacing="0" cellpadding="0" style="border:none"> <tr> ...

Dynamically adjust the label position based on the button position

I am currently developing an interface that allows users to change the position of buttons and add a label text under the button. However, I am facing an issue where the label is not always centered below the button due to variations in the size and number ...

What is the process for converting inline SVG images on the server?

Looking to use inline SVG as a background-image for another element? Check out this example that currently only works in Chrome. If you need an alternative method, take a look at the simpler inline SVG from the RaphaelJS demo here. <svg height="480" ve ...

The Font Awesome icons are failing to load properly and are displaying as square boxes in HTML

After cloning the website from HTTRACTs, I noticed a problem with the icons such as Facebook and Instagram appearing as squares on the entire pages. Upon inspecting the elements, I found that the error log was showing Failed to load resource: net::ERR_FILE ...

CSS - How can I position one div on top of another without them overlapping each other?

Hi there! I am having trouble positioning the lower div box next to the upper box with details. I tried using absolute positioning, but it keeps going down for some reason (I set the parent div of all three divs as position relative). Can someone help me f ...

Angular: Design dependent on attributes

Can I customize the styling of a div in accordance with a boolean property called "isActive" on my controller using Angular? <div class="col-md-3" (click)="isActive = !isActive"> <div class="center"> <i class="fa fa-calendar"& ...

Adjust the background color of Bootstrap 4 checkboxes

I'm trying to figure out how I can modify the background color of a Bootstrap 4 checkbox in this specific scenario. .custom-control-label::before, .custom-control-label::after { top: .8rem; width: 1.25rem; height: 1.25rem; } <link rel="style ...

What could be causing this table to exceed its dimensions by 2 pixels?

Why is the height of this table 102px instead of 100px? Is there another CSS attribute that needs to be set besides: table { border-spacing:0; border-collapse:collapse; } For example, check out this example link. ...

What is the best way to access all of a class's properties in JavaScript?

Is there a way to retrieve all the properties of a class using JavaScript? For example, if I have a class like this: .menu { color: black; width: 10px; } How can I extract "color: black; width: 10px;" as a string using JavaScript? Thanks in advance! ...

Having Difficulty Applying a Background Color to a Class in Bulk

I am working on a unique HTML canvas for pixel art, which is created using a table made up of various divs all sharing the "pixel" class. I want to add a clear button that can reset the entire canvas, but changing the background color of each individual di ...

Step-by-step guide on showcasing an image within the sidebar-wrapper CSS class

I am trying to include an image in the #sidebar-wrapper class using the code below: CSS: #sidebar-wrapper { background-image:url('/images/nav.jpg'); margin-left: -250px; left: 250px; width: 250px; position: fixed; height: 100%; ov ...