Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

CSS Sidebar CSS not working on desktop devices

On the pages of one of the site I'm currently working, the CSS is working fine for mobile devices, but it has no effect on desktop devices.

Code:
.arrow-link {
    display: flex;
    color: #246ddf;
    background-color: transparent;
    transition: all .4s ease;
    font-weight: bold;
    cursor: pointer;
    align-items: center;
    letter-spacing: 1px;
    font-size: 14px;
}
.arrow-link > .arrow {
    width: 8px;
    height: 8px;
    border-right: 2px solid #246ddf;
    border-bottom: 2px solid #246ddf;
    position: relative;
    transform: rotate(-45deg);
    margin-left: 3px;
    transition: all .4s ease;
}
.arrow-link > .arrow::before {
    display: block;
    background-color: #4fc42f;
    width: 3px;
    transform-origin: bottom right;
    height: 2px;
    position: absolute;
    opacity: 0;
    bottom: calc(-2px / 2);
    transform: rotate(45deg);
    transition: all .4s ease;
    content: "";
    right: 0;
}
.arrow-link:hover > .arrow {
    transform: rotate(-45deg) translate(4px, 4px);
    border-color: #4fc42f;
}
.arrow-link:hover > .arrow::before {
    opacity: 1;
    width: 8px;
}
.arrow-link:hover {
    color: #4fc42f;
}

For example, on this page, CSS works okay while browsing it on mobile devices.

But it has no effect on my Desktop screen.

I have tried experimenting with @media queries, but it had no desired effects.

Screengrabs are attached.
 

Attachments

  • kfi-desktop.jpg
    kfi-desktop.jpg
    195.3 KB · Views: 5
  • kfi-screen.jpg
    kfi-screen.jpg
    135 KB · Views: 5
What exactly isn't working on desktop?

Edit:
If I hit your link in Firefox, I see what matches your screengrabs and appears to work fine however if I use an emulator (BrowserStack) I see no navigation at all. Also in the cases of no nav, the URL was changes to include ?amp=1

Maybe your issue is with the AMP pages?
 
Last edited:
OK, sorry. I see what you are referring to in your question.

The css, when you inspect the arrow-links on mobile, is wrapped in a media query of: @media only screen and (max-width: 480px)

So, therefore, once you pass that max-width size, the styles are no longer applied.
 
OK, sorry. I see what you are referring to in your question.

The css, when you inspect the arrow-links on mobile, is wrapped in a media query of: @media only screen and (max-width: 480px)

So, therefore, once you pass that max-width size, the styles are no longer applied.
How to override this media query condition?
I have tried:
Code:
@media only screen and (min-device-width: 320px) and (max-device-width: 1920px)
{
.arrow-link {
    display: flex;
    color: #246ddf;
    background-color: transparent;
    transition: all .4s ease;
    font-weight: bold;
    cursor: pointer;
    align-items: center;
    letter-spacing: 1px;
    font-size: 14px;
}
.arrow-link > .arrow {
    width: 8px;
    height: 8px;
    border-right: 2px solid #246ddf;
    border-bottom: 2px solid #246ddf;
    position: relative;
    transform: rotate(-45deg);
    margin-left: 3px;
    transition: all .4s ease;
}
.arrow-link > .arrow::before {
    display: block;
    background-color: #4fc42f;
    width: 3px;
    transform-origin: bottom right;
    height: 2px;
    position: absolute;
    opacity: 0;
    bottom: calc(-2px / 2);
    transform: rotate(45deg);
    transition: all .4s ease;
    content: "";
    right: 0;
}
.arrow-link:hover > .arrow {
    transform: rotate(-45deg) translate(4px, 4px);
    border-color: #4fc42f;
}
.arrow-link:hover > .arrow::before {
    opacity: 1;
    width: 8px;
}
.arrow-link:hover {
    color: #4fc42f;
}
}

But it did not work out.
 
That's what I'm unable to remove.

So you don't have access to the code to remove the media query?

You can repeat the styles needed outside of any media query and the styles will be applied all the time. It will be duplicate code on mobile but it will work.

You can also add another media query:

@media only screen and (min-width: 481px) {}

and then repeat the styles needed to achieve what you need inside of that, but repeating the CSS without any media query should take care of it.
 
You seem to have made some effect as I am no longer seeing the arrows on this page on mobile or desktop:


The styles are listed as 'inline' so perhaps that can help you track it down? I am seeing some kind of utility classes so maybe Tailwind? Bootstrap?

In the inspector I am seeing the relevant css in "Inline Style Sheet #1" on line 4131

CleanShot 2024-10-04 at 08.40.15.png
 
Last edited:
That seems strange. Did you confirm that your new styles were being loaded? Are they being overridden somehow? Sounds to me that your new styles are being loaded/used on the page.
 
Back
Top Bottom