How to style a MenuButton's ContextMenu individually with CSS in JavaFX

I've been trying to figure out how to adjust the coordinates of a MenuButton's Context Menu using CSS, but I haven't had any luck so far. I attempted to use the "top" property in CSS, but it didn't work. I also tried using padding, but that didn't work either.

CSS

.menu-button {
    -fx-background-color: #8400d4;
}

.root {
    -fx-background-color: #ba5555;
    -fx-padding: 10;
}

.context-menu {
    -fx-background-color: #006699;
    -fx-text-fill: white;
    -fx-padding: 5em 0 0 0 ;
    top: 5em;
}

.menu-item .label {
    -fx-text-fill: #11534b;
}

.menu-item:focused .label {
    -fx-text-fill: white;
}


Example Picture :

https://i.sstatic.net/5FlB0.jpg

https://i.sstatic.net/GmdtT.jpg

Any ideas on how I could achieve this? Thanks in advance.

Answer №1

To achieve a vertical opening effect, consider utilizing the -fx-translate-y CSS property:

.menu-button:open-vertically .context-menu {
    -fx-translate-y: 20;
}

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

Ensuring Text Presence with Selenium using JavawaitForText()

During tests, I often encounter a situation where only part of the text appears in the text box instead of the entire text. For example, if I enter "cars" sometimes only "car" is displayed. My question is how can I ensure that the entire text is displayed ...

The <h> tag gains height on its own accord

Here is my original code: <h4 class="orange2" ><a href="<?php echo base_url();?>v/<?php echo $this->uri->segment(3);?>/<?php echo $v['uniq'];?>"><?php echo trim(strip_tags($v['video_name']));?> ...

Utilizing Maven Archetype Generate within the current working directory

Is there a way to run mvn archetype:generate and target the current directory instead of creating a new directory based on the artifactId? Despite attempting to pass in "-Dbasedir=." as the parameter, it doesn't seem to work. To provide more backgrou ...

Closing an Electron Dialog triggers a refresh on my current page

I currently have an Electron application in place. It utilizes Bootstrap v4, Electron v2, as well as other node modules. One concern I am facing is related to a button that triggers an Electron dialog box where users can select a folder. Upon selecting th ...

Show or conceal input fields depending on the selection of radio buttons

Hello everyone, I am new to JavaScript and currently learning. Can someone please assist me in fixing this code? The required inputs are: radio-button-1; radio-button-2; input-fields-set-1; input-fields-set-2; input-field-submit. My objective is: Upon ...

Unable to showcase significantly large calculation values in the editText field

private TextView info; private EditText input; private Button getInfo; long answer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getInfo = (Button) f ...

What's the strangest glitch in Chrome related to repainting?

I am currently facing an issue with a form that contains hidden errors. The CSS for this form, written in Stylus, is as follows: span.error display: none position: relative padding: .25em .5em width: 75% margin-top: 5px margin-bottom: 15px f ...

What is the reason for the image not being positioned in the top left corner of the html page?

My simple HTML page consists of only one image: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Anz ...

Implementing multiline ellipsis without relying on -webkit-line-clamp

Content is dynamically loaded in this p tag. I am looking to implement text ellipsis after a specific line (for example, show text ellipsis on the 4th line if the content exceeds). p { width: 400px; height: 300px; text-align: justify; } <! ...

The erratic appearance of inactive elements within ExtJS components

I am currently working on an ExtJS form that utilizes hbox-layout containers to generate sentences containing various form inputs. There is a specific requirement to disable the form under certain conditions. These hbox-layout containers consist of compone ...

What methods can be used to ensure a div reaches all the way down to a sticky footer?

I'm currently working on a layout with a sticky footer, and I have a specific div that needs to extend all the way down to the footer. However, simply setting the height to 100% doesn't achieve the desired result. I've also experimented with ...

Smart method for repositioning multiple elements on the display

Imagine we have multiple divs displayed on a screen: https://i.stack.imgur.com/jCtOj.png ...and our goal is to move them collectively, either to the left: https://i.stack.imgur.com/KBfXC.png ...or to the right: https://i.stack.imgur.com/c1cUw.png An ...

The carousel image slider seamlessly transitioning from the second image

I'm having an issue with the Carousel slider where it is overlapping the image from the second slide onwards. The first image loads properly, but subsequent images are not displaying correctly. Here's a reference image: https://i.sstatic.net/pyY ...

"Transitioning from jQuery to Vanilla Javascript: Mastering Scroll Animations

I'm seeking guidance on how to convert this jQuery code into pure Javascript. $('.revealedBox').each(function() { if ($(window).scrollTop() + $(window).height() > $(this).offset().top + $(this).outerHeight()) { $(this).addCla ...

Center 3 elements horizontally using Flexbox, ensuring the center element is aligned properly

Is it possible to center 3 elements using flexbox on a page? The middle element should be centered on the page, while the left and right elements can vary in width. Please refer to the image below: https://i.sstatic.net/IVdz8.png I am not certain if this ...

Chrome is where all the action happens, while Firefox prefers to keep things on the left

After a long break, I returned to designing my website and re-learning CSS. My approach involved creating a WordPress-integrated site with minimal HTML/PHP work, focusing more on utilizing the available CSS classes and IDs provided by a template theme (Bla ...

Exploring Unicode Symbols for Icon Selection

I'm currently working on integrating an icon picker into my application that will enable the user to select a mathematical operator for data comparison. While I have successfully implemented the fontawesome-iconpicker on the page, I am encountering d ...

What mistakes have I made in this CSS code?

Check out the REQUEST FORM in the image below (with a green background). It is currently aligned at the top, but I would like it to be centered vertically. https://i.sstatic.net/4A6Tw.jpg This is the CSS style being used, .rtitle { background-color: Gre ...

Z-index problem occurring with rotateY on Safari and Chrome Mobile

https://jsfiddle.net/nxbg7rq3/ I've been struggling to get the .mask completely on top of the .screen in this example. It works fine in most browsers, but Safari and Chrome Mobile are giving me a hard time. I've experimented with various solutio ...

Encountering challenges when using selenium webdriver to translate web pages from various languages to English

My challenge involves converting various links in different languages to English using Selenium JAVA after the page has loaded. Currently, this can be done manually by right-clicking on the page and selecting the "translate to English" option once it loads ...