r/FirefoxCSS • • 6d ago

Solved Is it possible to change the way basic html elements look?

/r/firefox/comments/1xz4j0a/is_it_possible_to_change_the_way_basic_html/
3 Upvotes

8 comments sorted by

1

u/t31os 3d ago edited 3d ago

I don't know what you mean by making the options flatter (please explain what you mean or provide an illustration), but you can restrict the height of the select dropdowns using userChrome.css.

Select dropdowns are part of the browser's chrome dom and use a general menupopup and arrow scrollbox, which are rendered in shadow dom'ed parts, but you can match the ID for dropdown popup, set a variable, then check for the presence of that variable when setting max-height on the arrowbox (as you don't want to apply this generally to all arrowboxes in the browser).

Eg:

#ContentSelectDropdownPopup {
	--uc-max-height: 100px !important;
}
.menupopup-arrowscrollbox {
	max-height: var( --uc-max-height, revert-rule ) !important;
}

I used 100px as an example (adjust as desired) so you can see the styling work with a select element, like the one here:

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/select

1

u/Acasiop 3d ago

Firefox on the left and Opera on the right; Opera is what I'd like it to look like. So that's what I mean by flatter.

1

u/t31os 3d ago

Give this a shot:

#ContentSelectDropdownPopup {
	
	--uc-arrowbox-max-height: 450px !important;
	--uc-arrowbox-padding: 0 !important;

	--menuitem-padding-inline: 5px !important;
	--menuitem-text-padding-block: 3px !important;
}

.menupopup-arrowscrollbox {
	max-height: var( --uc-arrowbox-max-height, revert-rule ) !important;
	padding: var( --uc-arrowbox-padding, revert-rule ) !important;
}

Adjust values as desired.

1

u/Acasiop 3d ago

That worked great, thank you!

#ContentSelectDropdownPopup {
  --uc-max-height: 402px !important;
  --uc-arrowbox-max-height: 402px !important;
  --uc-arrowbox-padding: 0 !important;
  --uc-arrowbox-border-radius: 0px !important;
  --menuitem-padding-inline: 5px !important;
  --menuitem-text-padding-block: 0px !important;
}

.menupopup-arrowscrollbox {
  max-height: var( --uc-arrowbox-max-height, revert-rule ) !important;
  max-height: var( --uc-max-height, revert-rule ) !important;
  padding: var( --uc-arrowbox-padding, revert-rule ) !important;
  border-radius: var( --uc-arrowbox-border-radius, revert-rule) !important;
  max-height: var( --uc-max-height, revert-rule ) !important;
}

Is what I went with. Would like to change the colours and box rounding as well but don't care enough to figure it out.

1

u/t31os 3d ago

You duplicated some of the styling there, sorry that's my fault for changing the variable names mid discussion, this should be fine.

#ContentSelectDropdownPopup {
  --uc-arrowbox-max-height: 402px !important;
  --uc-arrowbox-padding: 0 !important;
  --uc-arrowbox-border-radius: 0px !important;
  --menuitem-padding-inline: 5px !important;
  --menuitem-text-padding-block: 0px !important;
}

.menupopup-arrowscrollbox {
  max-height: var( --uc-arrowbox-max-height, revert-rule ) !important;
  padding: var( --uc-arrowbox-padding, revert-rule ) !important;
  border-radius: var( --uc-arrowbox-border-radius, revert-rule) !important;
}

The only instance(s) in which you'll need to apply styling in userChrome.css is when it relates specifically to the dropdown menu component of the select element, the rest of the element exists in the regular webpage dom and should usually be left to the given website to style.

If you really need to set some base level styling for the select/option elements, you can do that in userContent.css, either globally (overriding any values a website is trying to set), potentially breaking visual parity with that website's design and color scheme, or scoping the rule to only apply to specific sites, eg:

@-moz-document domain("google.com") {
	select {
		background-color: red !important;
	}
}

1

u/Acasiop 1d ago

Ah, so I did. Did not notice that while adjusting everything.

And I really don't want to mess around with it any more than I have. It'd be nice to get it to look exactly like it does in Opera but this is already plenty good.

1

u/t31os 1d ago edited 1d ago

This is pretty close for me (comparing FF and Opera side by side):

https://i.postimg.cc/7HLJ3W8c/ff-opera-select.png

userChrome.css

#ContentSelectDropdownPopup {

	--uc-arrowbox-max-height: 402px;
	--uc-arrowbox-padding: 0;
	
	--panel-border-radius: 0 !important;
	--menuitem-border-radius: 0 !important;
	--menuitem-text-padding-block: 3.5px !important;
	
	/* The blue shade here is darker on my install of Opera, so adjust as desired */
	[class^="ContentSelectDropdown-item-"]:is(:hover,[_moz-menuactive]) {
		background-color: #1967D2 !important;
		color: white !important;
	}
}

.menupopup-arrowscrollbox {
	max-height: var( --uc-arrowbox-max-height, revert-rule ) !important;
	padding: var( --uc-arrowbox-padding, revert-rule ) !important;
}

userContent.css

select {
	border-radius: 0;
	border-width: 1px;
	border-style: solid;
	background-color: Field;
}

Leave out !important and keep the selector low specificity for the userContent.css part and websites shouldn't have any issues overriding the styling.

1

u/Acasiop 1d ago

Worked great!