Customizing SO's snippets selection background - css
I am currently trying to create a dark SO theme with Stylish.
Everything was going great until I had to customize the snippet.
I can't seem to change the selection color to any other than the one predefined :
.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{
background:#d7d4f0;
}
I tried adding this, but nothing is changing :
.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{
background: blue !important;
}
Is there anyway to change the selection background here?
Here's the complete CSS from the theme, if it helps :
body, #questions div, .qa-block, #content {
background:#282828 !important;
}
#footer.categories {
background:#181818 !important;
}
.post-text {
background:#D5D5D5 !important;
color:#000000;
}
h1, h2, h3, h4 .page-description td, p, .owner-revision span, .revision span, div.container, #mdhelp pre, .badgecount, .comments, .user-panel-content td, .user-panel-content th, .content-page, .viewcount, .welovestackoverflow, .vote-count-post, .summarycount, #sidebar.module p .vote-count-post, .answer-votes, div.comment-body, h1 a, h4, span.reputation-score, div.module.question-stats p, span.page-numbers, #newsletter-ad, .item-summary, div.new-about-content-page.about-content-page div h2.about-title, .module.newuser, .page-description td, .bulletin-title, .status.answered span, .status.answered div, .label-key b, .excerpt, .answer-help, #mdhelp, .rep-col .rep, .user-card .user-card-name, #avatar-card .reputation {
color:#C0C0C0 !important;
}
.user-stats .stat span, #avatar-card .badgecount, #badges-table .badges-number {
color:#666 !important;
}
.revision-comment, .user-info-rep, .user-info-rep .user-details, .nav.mainnavs li a, .tag-container .col, .tar-container .stat .number, .top-tags .tag-wrapper .tag-container .stat .number, .card, .jobs, .login-link.btn {
color:#C0C0C0 !important;
background: #303030 !important;
}
.vote-count-post, .votes {
color:#E3E3AC !important;
}
span.count, .badge-tag {
color: #FFFFFF !important;
}
.stats {
background-color:#C0C0C0 !important;
}
#questions .status.unanswered {
color:#C23B22 !important;
}
.status.unanswered span {
color:#777777 !important;
}
.diff-delete {
background:#501010 !important;
}
.diff-add {
color:#A0E0A0 !important;
background:#105010 !important;
}
#questions .status.answered, .user-about-me, .stats {
background:#353535 !important;
}
#reputationGraph, .graph {
background:#FFF !important;
}
.result-highlight {
color:#FFFFFF !important;
}
#questions .status.answered-accepted {
background:#759971 !important;
}
.answer-hyperlink:visited{
color:#A187BE !important;
}
a, h1>a:visited, .answer-hyperlink, .reputation a:visited {
color:#6ECFF6 !important;
}
.content-block, .on-topic-examples, .off-topic-examples, .topbar .header, .modal-content, .welovestackoverflow, .comment-user, .community-bulletin, .revision td, #nav-askquestion, .answer-votes, #tabs a, .tabs a, .nav.mainnavs li, .question-status, #newsletter-ad .company-ad-b, .company-ad-sb, #hero-content, .module.newuser, .subtabs a.youarehere, .user-show-new .user-header-slim .data, .page-numbers.current, .other-sites, .topbar .topbar-icon-on, .topbar .topbar-icon-on:hover, .answer-help-background, #mdhelp-tabs, .ad502-room, header, .topbar-dialog div.header {
background-color:#373737 !important;
}
.owner-revision td, .owner-revision .revision-comment, .owner-revision .user-details{
background: #4A5287 !important;
}
.comment-user.owner {
background:#2E5666 !important;
}
.comment-user {
padding:2px !important;
}
.post-tag, #toc {
background:#454545 !important;
border:0px !important;
}
.welovestackoverflow, .topbar-dialog {
border: 0px !important;
}
.mdhelp-tabs, #hireme {
border: 1px solid #888 !important;
}
.top-tags .tag-wrapper .tag-container .col {
border-right:2px solid #888 !important;
}
.module, #question-header, .question-summary, .subheader, #tabs > a, .tabs > a, .company-ad-b, .company-ad-sb, #hero-content, div.subtabs a, .page-numbers, .topbar-dialog li, .user-about-me, .user-show-new .user-header-slim .data, .comment td, .answer, .wmd-input, .wmd-button-bar, .wmd-preview, .grippie, .ad502-room, .card, .progress-bar div {
border-color:#888 !important;
}
.topbar-dialog {
background-color:#888 !important;
}
.post-signature.owner, .user-details, .tagged-interesting, #hireme {
background:#353535 !important;
}
.comment:hover, .js-gps-track:hover, .siteSwitcher-dialog li:hover, .inbox-item:hover, header .topbar-icon-on, header .secondary-nav .-item .-link:hover {
background:#555555 !important;
}
input {
background:#E5E5E5 !important;
color:#404040 !important;
}
#hmenus a:hover {
background:#606060 !important;
}
textarea {
background:#404040 !important;
color:#C0C0C0 !important;
}
.grippie {
background:#454545 !important;
}
.feed-icon {
background-color: rgba(255, 255, 255, 0) !important;
}
/* old logo */
#hlogo a {
background-image: url("http://i.imgur.com/zeNdkNx.png") !important;
background-size: 280px;
width:280px;
height:90px;
}
/* new header logo */
.so-header .-logo .-img {
background-image: url("https://i.imgur.com/lLtU6Nd.png") !important;
background-size: 150px;
width:150px;
height:30px;
background-position:0;
margin-top:-4px;
background-repeat:no-repeat;
}
.community-bulletin, .ad502-room {
box-shadow:none !important;
}
/* code colors */
.post-text {
background:#282828 !important;
color:#C0C0C0 !important;
}
.prettyprint, blockquote, pre, pre>.spaces, .hi, .badge-tag {
background:#353535 !important;
}
code {
background:#353535 !important;
color:#C0C0C0 !important;
}
.lit { /* literal */
color:#FF6961 !important;
}
.tag { /* tag */
color:#FF6961 !important;
}
.atn {
color:#C23B22 !important;
}
.atv {
color:#AEC6CF !important;
}
.str { /* string*/
color:#C23B22 !important;
}
.pln { /* plain text */
color:#E0E0E0 !important;
}
.pun { /* punctuation */
color:#A0A0A0 !important;
}
.com { /* comment */
color:#ACD372 !important;
}
.kwd { /* keyword */
color:#AEC6CF !important;
}
.typ { /* type */
color:#7EB1C4 !important;
}
.new-post-activity{
background-color: inherit;
}
.snippet-code{
border: none !important;
}
.snippet-holder{
background: #2a2a2a !important;
}
.CodeMirror-scroll{
background: #353535 !important;
}
.cm-def,.cm-atom,.cm-attribute,.cm-s-default{
color: #6262ff !important;
}
.cm-s-default .cm-keyword{
color: #9e1fb1 !important;
}
.cm-tag{
color: #44833a !important;
}
.cm-string{
color: #8d3535 !important;
}
.CodeMirror{
color: #C0C0C0 !important;
background: #353535 !important;
}
.CodeMirror-selected {
background: blue !important;
}
.CodeMirror-focused .CodeMirror-selected {
background: blue !important;
}
.CodeMirror-scroll .CodeMirror-line::selection,.CodeMirror-scroll .CodeMirror-line>span::selection,.CodeMirror-scroll .CodeMirror-line>span>span::selection{
background: blue !important;
}
.CodeMirror-gutters{
background: #424242 !important;
}
#snpte-box-edit-result{
background: #7d7d7d !important;
}
.snippet-modal .-code .column.result .-name{
color: #bebfbf !important;
}
.clc-cp-sb--short .-wrapper{
background-color: #3d3d3d !important;
}
.clc-cp-sb--short .-bg-image:after{
background-color: #484848 !important;
}
.clc-cp-container .clc-cp-tag{
background: #454545 !important;
}
.clc-btn-secondary{
background: #606060 !important;
}
.clc-cp-sb--tall{
background-color: inherit !important;
border: none !important;
}
.clc-cp-sb--tall .clc-cp-sb-learnmore-wrap{
background-color: inherit !important;
}
#hireme{
margin-bottom: 20px;
}
.mainbar.reviewable-answer,.comment.js-comment {
background-color: inherit !important;
}
#new-answer-activity, .new-post-activity{
background-color: inherit;
}
.p-highlights .-card{
background-color: inherit;
border: 1px solid #e4e6e8;
}
.p-highlights .-graph{
background-image: url(https://data.zenoo.fr/stackoverflow_lines.svg)
}
aside.-badges>div:first-of-type>div{
background-color: #202020;
border-color: #646363;
}
In codemirror.css, from line 321 you will see:
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
Copy these rules into your styleesheet.
Try replacing the background-color property with your custom color for all of these rules.
Try adding !important.
As far as I can tell, my comment on the sol answer is working
.CodeMirror-selected {
background: red;
}
.CodeMirror-focused .CodeMirror-selected {
background: red
}
So, thanks to #vals, I noticed that
.CodeMirror-selected {
background: red;
}
.CodeMirror-focused .CodeMirror-selected {
background: red
}
was working on its own, but not in my Stylish theme, I finally understood why:
The rule
.prettyprint, blockquote, pre, pre>.spaces, .hi, .badge-tag {
background:#353535 !important;
}
Was overwriting any background we tried to put on the selection. So I added a fix to it, targeting the Snippet line more precisely :
pre.CodeMirror-line{
background: inherit !important;
}
Now #vals solution is working :)
Thanks everyone for helping me solve this !
::-moz-selection { /* Code for Firefox */
background:#d7d4f0;
}
::selection {
background:#d7d4f0;
}
use this code it resolve your problem
Related
Change with CSS the background selection in firefox?
I'm trying to change the color of the background of the selection (Holdclick) of an item in Firefox with css This is what i'm refering to: I'm trying to remove that gray shade. I think it has to be done with code like this: #-moz-document url-prefix("about:"),url-prefix("chrome:"){ :root{ --in-content-button-background-hover: transparent !important; --in-content-button-text-color-hover: var(--color) !important; --in-content-button-background[selected]: var(--color) !important; } } But I'm not sure how to do it. With this code I'm able to do it so it doesn't happen in every option like the top ones: #-moz-document url-prefix("about:preferences") { #categories > .category { background-color: transparent !important; } #categories > .category[selected] { background-color: transparent !important; } #categories > .category:hover { background-color: transparent !important;} } Thanks! I've tried with this code, and it worked but only for the options ontop: #-moz-document url-prefix("about:preferences") { #categories > .category { background-color: transparent !important; } #categories > .category[selected] { background-color: transparent !important; } #categories > .category:hover { background-color: transparent !important;} } #-moz-document url-prefix("about:addons") { #categories > .category { background-color: transparent !important; } #categories > .category[selected] { background-color: transparent !important; } #categories > .category:hover { background-color: transparent !important;} } It didn't do it for the lower options.
PrimeReact: change background color of Menubar items when on hover
i can't change the menu items color when on hover As you can see, when on hover the color is shown only in the corners, but not on the actual item. This is my css code: /*Menubar*/ .p-menubar { background-color: var(--primary) !important; } .p-menu-list { background-color: var(--primary) !important; } .p-menuitem { background-color: var(--primary) !important; } .p-menu-list:hover { background-color: #000 !important; } .p-menuitem:hover { background-color: #000 !important; } .p-menuitem-text, .p-menuitem-icon, .p-submenu-icon { color: var(--text-primary) !important; }
If i understood correctly, you need this .p-menuitem-active a { background: #000 !important; } or this depending on whether you want it for hover or on expand .p-menuitem-link:hover { background-color: #000 !important; }
Move the label in angular material to above the input
I am currently using angular material in my project and I have been asked to move input labels. Currently when you start typing in an input, they move so the middle of the label is on the input top border. I need to move them to just above the top of the input. Here is an example of what it currently looks like: I tried to fix this myself by adding this sass: .mat-form-field-appearance-outline { .mat-form-field-outline-start, .mat-form-field-outline-end, .mat-form-field-outline-gap { border: 2px solid currentColor !important; } .mat-form-field-outline-gap { border-left: none !important; border-right: none !important; } .mat-form-field-outline-start { border-radius: 25px 0 0 25px !important; border-right: none !important; } .mat-form-field-outline-end { border-radius: 0 25px 25px 0 !important; border-left: none !important; } .mat-form-field-wrapper { margin: 0 !important; } .mat-form-field-flex { // This padding centers the text padding: 2.75px 25px !important; } .mat-form-field-infix, .mat-form-field-label-wrapper { border-top: 5px solid transparent; } .mat-form-field-outline { color: $off-white; background-color: $off-white; border-radius: 25px; } &.mat-form-field-invalid.mat-form-field-invalid .mat-form-field-outline-thick { color: $warm-red; // TODO: Add the theming } &.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-label, &.mat-form-field-can-float .mat-input-server:focus+.mat-form-field-label-wrapper .mat-form-field-label { transform: translateY(-30px) scale(0.75); } } .mat-form-field-label-wrapper { padding-top: 10px; } It's only these lines that actually move the label: .mat-form-field-appearance-outline { &.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-label, &.mat-form-field-can-float .mat-input-server:focus+.mat-form-field-label-wrapper .mat-form-field-label { transform: translateY(-30px) scale(0.75); } } .mat-form-field-label-wrapper { padding-top: 10px; } But I want you to see the rest of the formatting we use. The problem with my solution is that the text gets cut off: Does anyone know how to fix this?
In my case (Angular Material 11.0.0) it is a working solution: .mat-form-field-label-wrapper { transform: translateY(-20px) !important; } .mat-form-field-label { transform: translateY(-20px) !important; } edit: missing }
How can I delete the highlight color for nodes
I have an PrimeNg Tree (Angular 2) and I want to delete the selected nodes highlight color. Image Here Based on the image I want to delete the blue highlight color. Instead I want to get this style: Style I want Here are my styles: .ui-tree { width: 100%; } body .ui-widget-content { border: none !important; } span.ui-treenode-label { font-family: Poppins !important; line-height: 24px !important; font-size: 14px !important; padding-left: 5px !important; padding-right: 5px !important; } span.ui-treenode-icon { line-height: 24px !important; font-size: 1.2rem !important; } .ui-tree .ui-chkbox .ui-chkbox-icon { margin-left: 0px; } .ui-tree .ui-treenode-children { padding-left: 20px !important; } .hidden-tree-node { display: none; } .ui-state-highlight .ui-widget-content { color: white; }
You can override the original style by setting: span.ui-state-highlight { background-color: transparent !important; color: inherit !important; }
A few solutions: 1) Use ng-deep ::ng-deep { span.ui-state-highlight { background-color: transparent; color: inherit; } } 2)Target the element in a more specific way span.ui-treenode-label.ui-corner-all.ui-state-highlight { background-color: transparent; color: inherit; } Also, try to use SASS. It will make your CSS more readable and smarter. You will love it. By the way you should remove the importance from your code. using importants is not good practice.
How do I apply the same styling to all immediate children classes?
In less I have the following: .some-class{ > li{ a{ color: white; background: #fti-lightgrey; border-radius: 0px; padding: 1px 15px; // a color for the partcular tab that is chosen. (the color for each tab can be set inside mura) &.orange{ &:hover{ background: #fti-orange; } &:hover{ color: white; } } &.black { &:hover{ background: black; } &:hover{ color: white; } } &.topaz{ &:hover{ background: #fti-topaz; } &:hover{ color: white; } } } } } How do I avoid writing &:hover{ color: white; } multiple times? Is there a way to apply this line to all of the immediate class descendants somewhere inside the a tag?
It depends on the desired result. Do you want: 1) White hover color by default, regardless of whether it also has the one of the .orange, .black, or .topaz classes? .some-class{ > li{ a{ color: white; background: #fti-lightgrey; border-radius: 0px; padding: 1px 15px; // a color for the partcular tab that is chosen. (the color for each tab can be set inside mura) &.orange{ &:hover{ background: #fti-orange; } } &.black { &:hover{ background: black; } } &.topaz{ &:hover{ background: #fti-topaz; } } } a:hover{ color: white; } } } 2) Or do you only want it to be white on hover if it also has one of .orange, .black, .topaz classes? .some-class{ > li{ a{ color: white; background: #fti-lightgrey; border-radius: 0px; padding: 1px 15px; // a color for the partcular tab that is chosen. (the color for each tab can be set inside mura) &.orange{ &:hover{ background: #fti-orange; } } &.black { &:hover{ background: black; } } &.topaz{ &:hover{ background: #fti-topaz; } } } a:hover { &.orange, &.black, &.topaz{ color: white; } } } }
You could do a:hover { &.orange, &.black, &.topaz { color: white; } } then define the background individually. This is assuming the hover for your anchor is different colour than white by default and you want the coloured classes to be white(not in a human race way!). or use the same style as you have a { &.orange, &.black, &.topaz { &:hover { color: white; } } } if you have a common class for the colours then you could always target that common class
In this case I would recommend to simply remove &:hover { color: white; } rules, as long as you have it set on a tag already and there is no something like a:hover rules which might override this. In case if you have some a:hover rule with different color, simply add &:hover { color: white } right inside of a block. .some-class{ > li{ a{ color: white; background: #fti-lightgrey; border-radius: 0px; padding: 1px 15px; // a color for the partcular tab that is chosen. (the color for each tab can be set inside mura) &.orange{ &:hover{ background: #fti-orange; } } &.black { &:hover{ background: black; } } &.topaz{ &:hover{ background: #fti-topaz; } } } } }