Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #938411

    I am using the Code Block element on a webpage, and the background lines alternate between white (#ffffff) and light gray (#f3f3f3). I’d like to change those two to much darker colors since (1) the text in that area is styled white from the theme settings and (2) a darker code area will stand out more on the page.

    I’m not sure how to accomplish this.

    #938426

    Hey lbccomm,

    You are looking to change it on the front-end? Please add a link to the site/page in question so we can look into this issue further.

    Best regards,
    Jordan Shannon

    #938438

    I’m in the middle of updating the page, so it’s kind of a mess at the moment.

    Start scrolling down and you’ll find a list shortly. The code block is located in #5 (this will make sense when you see it). This entire list is contained within a “Color Section” where the Section Background has been set to “Alternate Content.” The settings for Alternate Content is a blue background with white text. That’s fine for most of the site, however, for this section I want a white background. For text within a Text Block, I just change the text color to a dark gray (#cccccc).

    My dilemma is that the text within the Code Block is being formatted white, and the code background is also white/light.

    So, in reality, I either need to be able to force the text to be dark, or the background.

    My assumption is that this can be resolved with CSS, but I’m not 100% sure.

    For clarity: Just passed where I’m having this issue you will see the code working just fine. I am replacing that, so it will be deleted.

    Thanks!

    #938443

    you see here the code concerning to pre background:

    pre {
        clear: both;
        border-style: solid;
        border-width: 1px;
        overflow: auto;
        padding: 2em;
        line-height: 2em;
        font-size: 12px;
        background-image: -webkit-linear-gradient(rgba(0, 0, 0, .05) 50%, transparent 50%, transparent);
        background-image: -moz-linear-gradient(rgba(0, 0, 0, .05) 50%, transparent 50%, transparent);
        background-image: linear-gradient(rgba(0, 0, 0, .05) 50%, transparent 50%, transparent);
        background-size: 100% 4em;
        font-family: Monaco, "Andale Mono", "Courier New", Courier, monospace;
        -webkit-transition: all ease-in-out 0.5s;
        -moz-transition: all ease-in-out 0.5s;
        transition: all ease-in-out 0.5s;
        margin-bottom: 30px;
        position: relative;
        left: 0;
        text-transform: none;
        width: 100%;
    }

    it is here which rules the background – try this:

        pre { 
    background-image: -webkit-linear-gradient(rgba(0, 0, 0, .2) 50%, transparent 50%, transparent);
    background-image: -moz-linear-gradient(rgba(0, 0, 0, .2) 50%, transparent 50%, transparent);
    background-image: linear-gradient(rgba(0, 0, 0, .2) 50%, transparent 50%, transparent);
    }

    you see 50% are light gray – 50% are transparent

    #938445

    btw: if you want to have more line-height:
    padding and line-height must have the same value
    background-size : width 100% and double line-height comes to height here ( 2em, 2em – 4em)
    if you want 3em line-height you have to have 3em padding (important is top -bottom value) and background-size: 100% 6em

    #938573

    Hi,

    Thanks for helping out @guenni007, did you try any of the suggestion out @lbccomm?

    Best regards,
    Rikard

    #938697

    I added the following code to the Custom CSS area:

    /* DARKENS CODE BLOCK */
    pre {
    background-image: -webkit-linear-gradient(rgba(0, 0, 0, .7) 100%, transparent 100%, transparent);
    background-image: -moz-linear-gradient(rgba(0, 0, 0, .7) 100%, transparent 100%, transparent);
    background-image: linear-gradient(rgba(0, 0, 0, .7) 100%, transparent 100%, transparent);
    }

    There’s no variation between the lines, but I don’t need any. That worked great. Thanks a lot!

    #938737

    Hi,

    Great, glad you got it working and thanks for sharing your solution. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #938750

    in this case if you are sattisfied with no lines you can do instead:

    pre {
    background: rgba(0, 0, 0, .7);
      color: #fff 
    }
    #938783

    Hi,

    Thanks for sharing @guenni007 :-)

    Best regards,
    Rikard

    #938897

    That cleaner code worked as well. Thanks for everything. We’re done!

    #938969

    Hi lbccomm,

    Great, glad you got it working. Shall we close this thread then?

    Best regards,
    Rikard

    #939310

    Yes. Thank you!

    #939474

    Hi,

    I’m glad you were able to get this corrected. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Change color of code block’ is closed to new replies.