Trouble with partial page displaying incorrect CSS class

I have created CSS classes for generating circles with different colors. When I apply the CSS class in a regular HTML file, it displays correctly as expected. However, when I try to use it in an AngularJS partial page, the circle does not render properly.

Correct Example: https://i.sstatic.net/IodUY.png Incorrect Example: https://i.sstatic.net/1wnyG.png

Below is the CSS class for creating red circles:

.red-circle {
  margin: 40px auto 0;
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 1px solid #c92c09;
}
.red-circle:before, .red-circle:after {
  content: '';
  width: 15px;
  height: 30px;
}
.red-circle:before {
  float: left;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  background: #c92c09;
}
.red-circle:after {
  float: right;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  background: #c92c09;
}

Here is how the correct HTML page uses the CSS class:

<link rel="stylesheet" href="../css/circles.css" type="text/css" />
 <body>      
      <div class="red-circle"><div>
    </body>

And here is the incorrect HTML that results in improper display of the circle:

<div class="container" ng-controller="FieldCtrl">
    <link rel="stylesheet" href="../css/circles.css" type="text/css" />
    <div class="red-circle"> </div>
</div>

Answer №1

Simply include position and top, then eliminate the floats. Instead, make use of right and left

CSS

.red-circle {
  margin: 40px auto 0;
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 1px solid #c92c09;
  position: relative;
}

.red-circle:before,
.red-circle:after {
  top: 0;
  position: absolute;
  content: '';
  width: 15px;
  height: 30px;
}

.red-circle:before {
  left: 0;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  background: #c92c09;
}

.red-circle:after {
  right: 0;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  background: #c92c09;
}

.container {
  display: inline-block;
}

VIEW DEMO HERE

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

Transforming SQL data into JSON format for Treeview using C#

I have a stored procedure that retrieves data from a table. I am looking to transform it into the following format: data: [ { text: "Furniture", items: [ { text: "Tables & Chairs" }, ...

How can we initiate a script once the scroll has reached the designated block using jQuery?

I am using a unique jQuery script that I created myself, and I want it to activate when the scroll reaches the tab block (the blue and grey block at the end of the page). Check out the live version This is my HTML: <section id="Block" class="containe ...

Should instance variables be imported into Angular from Ruby on Rails? If so, what is the best way to do it?

I am currently developing a web application that utilizes Angular on the client side and Ruby on Rails on the backend. The app will be displaying a dynamically generated list of articles. One thing I'm considering is the typical model of interactions ...

A gap only appears in the drop-down navigation when the page is scrolled

After finally completing my first website, I encountered a frustrating issue. When scrolling down the page, a gap appears in the navigation bar, making it impossible to access the dropdown menus. I've been struggling to fix this problem on my own. Any ...

Unable to modify the border color of the outline in MUI text fields

I am currently working on a React project using MUI and styled-components, but I am facing an issue with changing the outline border color of a textfield. Despite reading the documentation and attempting to overwrite the class names of the component, it do ...

How to perfectly center a dropdown menu using CSS across different web browsers

I am dealing with a dropdown menu that is auto-generated by WordPress, so altering the HTML structure is not an option. However, I have the flexibility to adjust the CSS styling to correct an alignment issue in my dropdown menu. Currently, I'm facing ...

Error message indicating an issue with ng-repeat when working with an

$http.get('***').success(function(data, status,response) { $scope.items=data; var getdata=JSON.stringify(data.D_Services); console.log(getdata); }); im retrieving in the console D_Services: "Wash,Tyres,Spares,Accessories"; Could someone please ...

AngularJS Chrome Extension has been flagged as potentially harmful, despite the implementation of compileProvider.aHrefSanitizationWhitelist. This has resulted

I have previously shared this issue, however, the suggested solutions did not resolve it. Therefore, I am reposting with a more widely recognized solution: I am currently working on developing a chrome extension using AngularJS. In my base directive, I am ...

Can the card overlay slide appear solely on top of the image?

I am trying to create a gallery section of cards using Bootstrap 4 where I want the user to hover over each card and have an overlay slide or fade in, covering only the image. Currently, the overlay slides in over the entire card instead. I have been stru ...

Is there a way to extract just the date portion from the string "2017-11-13T00:00:00" using AngularJS?

I am looking for a way to extract only the date portion from "2017-11-13T00:00:00" using AngularJS. I attempted to achieve this using the following method: &scope.date = "2017-11-13T00:00:00"; var dateParts = $filter('date')(new Date(&sc ...

The issue occurs when using z-index: -1 in Google Chrome causes links to malfunction

Recently, I encountered an issue with Chrome. When I applied a z-index of -1 to a position: relative; unordered list, the links within it became unclickable. You can see an example at http://jsfiddle.net/raLnx/ using Chrome 20.0.1132.47m. There is no pro ...

When applying a maximum width of 100% with automatic height, images may become cropped

I'm a beginner in learning CSS, and since my technical skills are limited, I'll try to keep things simple. Currently, I have an image taking up half of the screen with the following CSS code that I found after reading some articles: <div class ...

Looping animations using AngularJS

I have implemented a custom directive to trigger an animation on an element when a specific field is empty on the page. However, I am facing an issue where the animation only works once when the user clicks the button with the directive. Subsequent clicks ...

Is there a way to verify that an array is not NULL in AngularJS?

Looking for an elegant solution in AngularJS to check if the array is not null or has a length greater than 0. var someArr = [1,2,3,4,5]; ...

Issue with Ionic displaying data from AngularJS $http.get request

Having just started learning AngularJS, I have followed tutorials on YouTube and read the documentation, but I am struggling to display data from an API using the $http.get() request. Here is my JavaScript and HTML code: var exampleApp= angular.modul ...

Issues with the proper functioning of the mr-auto class in Bootstrap 4

I am currently working with a code snippet: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin=" ...

Creating a CSS layout that eliminates the need for a vertical scroll bar

Currently, I am experimenting with creating an HTML CSS Layout using the div tag. You can view the code here Currently, the layout displays a vertical bar that I would like to eliminate. Ideally, I only want it to display if the content is lengthy. ...

Arrange the footers in the bootstrap card deck to be perfectly aligned at the top

Using bootstrap 4 to showcase cards has been successful, but there is an issue with footers that have varying content lengths. Instead of the footer adjusting its position based on the content, is there a way to keep the tops aligned while pushing the cont ...

Ionic: How come my image is not loading with HTTP.GET?

I have been attempting to populate a gallery in my Ionic application by fetching images from a JSON file, but I am encountering issues. While following a guide on creating a grid-like image gallery using the Ionic framework (https://blog.nraboy.com/2015/03 ...

Customize default progress bar in browsers

One feature of my website allows users to update their personal information, profile image, background image, and more. After clicking the submit button, a loading screen appears with a progress percentage displayed at the bottom left corner of the page (i ...