"Troubleshooting: Issue with CSS code on Codepen when trying to create

I am attempting to replicate the Google logo using HTML and CSS.

While the code functions properly in browsers, there seems to be an issue with Codepen not positioning the horizontal blue line correctly.

How can this be resolved?

What adjustments should be made to the .horizontal-color class properties to ensure consistent performance across Codepen and browser platforms?

Currently, the following code is functioning seamlessly in all web browsers:



  <body>
    <div class="wrap">
      <div class="color3"></div>
      <div class="right-center-color"></div>
      <div class="horizontal-color"></div>
    </div>
    <div class="wrap"></div>
    <div class="wrap"></div>
  </body>
</html>

* {
  box-sizing: border-box !important;
}

body {
  margin: 0;
  padding: 0;
  background: #233637;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

html {
  font-size: 125%;
}

.wrap {
  width: 15rem;
  height: 15rem;
}

.wrap:nth-child(1) {
  position: relative;
}

.wrap:nth-child(2) {
  position: absolute;
  border-radius: 50%;
  border-top: 3rem solid transparent;
  border-right: 3rem solid transparent;
  border-bottom: 3rem solid #2ba14b;
  border-left: 3rem solid transparent;
  transform: rotate(20deg);
}

.wrap:nth-child(3) {
  position: absolute;
  border-radius: 50%;
  border-top: 3rem solid #e33e2b;
  border-right: 3rem solid transparent;
  border-bottom: 3rem solid transparent;
  border-left: 3rem solid transparent;
  transform: rotate(-20deg);
}

.color3 {
  position: absolute;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  border-top: 3rem solid #e33e2b;
  border-right: 3rem solid transparent;
  border-left: 3rem solid #f1b500;
  border-bottom: 3rem solid #2ba14b;
}

.right-center-color {
  position: absolute;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  border: 3rem solid transparent;
  border-right: 3rem solid #3a7cec;
  transform: rotate(45deg);
  z-index: -1;
}

.horizontal-color {
  height: 3rem;
  width: 8rem;
  background-color: #3a7cec;
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  border-bottom-right-radius: 1.5rem;
}

Answer №1

It seems like you have included the entire HTML code in CodePen, which is why it is not functioning as expected. To fix this issue, simply include only the body part of the HTML code in CodePen. The head section is not necessary for CodePen to work properly. Once you make this adjustment, your code should work perfectly.

  <body>
    <div class="wrap">
      <div class="color3"></div>
      <div class="right-center-color"></div>
      <div class="horizontal-color"></div>
    </div>
    <div class="wrap"></div>
    <div class="wrap"></div>
  </body>

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

After updating the INNERHTML, the NAV tag content is no longer functional

I am facing an issue with replacing the contents of a NAV tag that contains UL list items. The original HTML within the NAV tag works perfectly fine, but when I replace it with my own HTML - which matches the original word for word - the dropdown functiona ...

Adjust the height and width dynamically in CSS/HTML based on various screen dimensions

There are 2 major concerns I have regarding this layout : .feature_content (with a grey background) does not adjust its height and width to different screen sizes. Currently, on large screens, .feature_content is positioned far from the footer. There is ...

What are effective strategies to stop the generic * { … } style from overriding its parent tag?

How can I prevent my general * { ... } style from overriding the parent tag? In the given scenario, I want the text "sssssssss" to have the style text-huge. .text-huge { font-size: 28px !important; color: green !important; } * { font-size: 12px; ...

The navigation bar options are not collapsing as intended

When I resize my page to width:750px;, my navigation bar is not collapsing the items. Despite trying to edit my CSS, I am still clueless. Here is my live page. This is the CSS for my slidebar: @media (max-width: 480px) { /* Slidebar width on extra small ...

What causes the size of text to change when I zoom in my browser?

As I work on my website, I am facing a challenge with maintaining consistent text size as the page scales. For example: p { width: 10%; height: 10%; background-color: rgb(0,0,0); top: 50%; left: 50%; position: fixed; color: rgb(255,255,25 ...

You may only insert a single image into a container

My goal is to display two images side by side with text centered between them. However, when I add the first image using CSS and the background property, I run into issues adding a second image as it overrides the first one. Placing the images directly in ...

Achieve an overlapping effect with grid items

I'm in the process of creating a CSS grid layout where the header overlaps the next row. Below is a snippet of my code with the header positioned on top, and the linked image should give you an idea of what I'm aiming for. Thank you! https://i ...

Is there a way to turn off the "swipe to navigate back" feature in Microsoft Edge using JavaScript or jQuery?

Working on a website that features horizontal object rotation. For instance, starting with the front view of an object followed by side, back, other side, and then back to the front. In this case, there are 24 images of an object, each taken at a 15 degre ...

CSS vertical text not functional as expected

Trying to make some text vertical, here is the CSS I'm using: h2.verticle{ color:#1a6455; border:0px solid red; writing-mode:tb-rl; filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); -webkit-transform:rotate(90deg); -moz-transform:rota ...

A pair of boxes sitting next to each other, both occupying 50% of the space but slightly longer in length and not aligned on the same level

My goal is to have two side-by-side boxes that fill the entire width of the screen. However, I'm facing an issue where each box exceeds 50% width by about 10 pixels. What could be causing this discrepancy? #sides { padding-top: 40px; padding- ...

Tips for integrating CSS keyframes in MUI v5 (using emotion)

Hey there! I'm currently working on adding some spinning text, similar to a carousel, using keyframes in my React app. The setup involves MUI v5 with @emotion. Basically, I want a "box" element to show different words every few seconds with a rotating ...

To highlight errors in ASP.NET MVC4 form validation, consider adding a vivid red border around the selectize dropdownlist

I have implemented the selectize framework for my dropdown list in asp.net mvc4 and successfully modified the CSS for all form fields bound to asp.net mvc4's validation engine. However, I am facing an issue with creating a border around the dropdownl ...

What is the best way to show inline icons within menu items?

Issue Upon selecting an option from the menu, I encounter a problem where the icon (represented by a question mark inside a speech bubble) appears on a different line than the text ("Question"). Fig. 1. Display of menu after selection with the icon and t ...

In this guide, we will explore the process of designing unique styles for ng

What is the proper way to customize CSS for a specific element? &.ng-select-focused { &:not(.ng-select-opened) > .ng-select-container { border-color: $ng-select-highlight; box-shadow: $ng-select-box-shadow; } } The offi ...

Guide to aligning form data with Bootstrap

Struggling to align my form data in the center below. I have attempted various online solutions without success. The use of bootstrap and offset is causing issues with the title for the form and the actual form itself. Any suggestions would be highly appre ...

Is there a way to remove this annoying double Google search bar?

Looking to replicate the Google home page for a project using HTML and CSS. I'm having trouble with incorporating the highlighted code (as shown in the second picture and identified by bold and italicized text) into my code. When I try to add it, I en ...

Bordering the isotopes

Currently, I am utilizing a plugin that involves the isotope filter library. By setting the width to 33.33%, my list elements are organized into 3 columns. I am trying to specify the middle column to have side borders. However, whenever I click on the filt ...

locate the following div using an accordion view

Progress: https://jsfiddle.net/zigzag/jstuq9ok/4/ There are various methods to achieve this, but one approach is by using a CSS class called sub to hide a 'nested' div and then using jQuery to toggle the Glyphicon while displaying the 'nest ...

Switching the sorting criteria from 'AND' to 'OR' in the JPList library

I am currently exploring the use of JPList to sort on multiple items. As it stands, JPList searches like 'AND' when sorting (e.g. sorting based on an item with tags html, php and jQuery all together), but I am interested in filtering through all ...

Utilizing the '::marker' pseudo-element for generating Markdown-inspired headers

This code snippet is functioning correctly, however, I have a suggestion to make it more appropriate. Instead of using '::before', why not try using '::marker'? I attempted this adjustment but encountered an issue. Can anyone explain wh ...