Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pseudo element affecting outline [duplicate]

Tags:

html

css

Pretty sure this is a bug with Firefox, but perhaps someone can weigh in.

I am applying an outline around a 100x100 box. When you use a pseudo element that is positioned absolute it should remove it from document flow, but it appears it still is affecting the flow of the outline property. IE and Chrome appear to render this as I would expect, where the black outline stays positioned to the main element. Any ideas?

enter image description here

.content
{
  width:100px;
  height:100px;
  outline:1px solid black;
  border:1px solid yellow;
  position:relative;
}

.content:after
{
  position:absolute;
  content:'pseudo';
  background-color:salmon;
  width:200px;
  top:150px;
}
<div class='content'></div>

http://jsbin.com/gatupogiwi/1/edit?html,css,output

like image 885
cgatian Avatar asked Aug 07 '15 17:08

cgatian


People also ask

What is the purpose of pseudo-elements?

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). For example, ::first-line can be used to change the font of the first line of a paragraph.

When would you use the :: before or :: after pseudo-element in your CSS?

One simple example of using ::before pseudo-elements is to provide quotation marks. Here we use both ::before and ::after to insert quotation characters.

Which of the following pseudo-element will help you add an image before every paragraph using CSS only?

CSS - The ::before Pseudo-element The ::before pseudo-element can be used to insert some content before the content of an element.

What is the use of :: after in CSS?

In CSS, ::after creates a pseudo-element that is the last child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.


1 Answers

You can change the outline style to box-shadow:

outline:1px solid black;

to:

box-shadow: 0px 0px 0px 1px black;
like image 82
Anthony Avatar answered Nov 15 '22 06:11

Anthony