Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To use * selector in a container is dangerous #6

Open
Dafrok opened this issue Jan 29, 2018 · 2 comments
Open

To use * selector in a container is dangerous #6

Dafrok opened this issue Jan 29, 2018 · 2 comments

Comments

@Dafrok
Copy link

Dafrok commented Jan 29, 2018

The code below makes all elements in the device container to be block level, that's not a good idea I suppose.

.device,
.device * {
  &,
  &::before,
  &::after {
    box-sizing: border-box;
    display: block;
  }
}

.device * {

@do-adams
Copy link

do-adams commented Jul 25, 2019

I agree, this seems like bad practice. This CSS makes it impossible to properly render nested HTML content within the .device-content block of the .device.

I managed to fix this by modifying the base devices.css styles with this:

.device,
.device::before,
.device::after,
.device > *,
.device > * > *,
.device > *::before,
.device > *::after,
.device > * > *::before,
.device > * > *::after {
  box-sizing: border-box;
  display: block;
}

It works well so long as the device structure follows the pattern (which all of the devices as of v0.1.16 do):

<div class="device device-iphone-x">
  <div class="device-frame">
    <img class="device-content" src="...">
  </div>
  <div class="device-stripe"></div>
  <div class="device-header"></div>
  <div class="device-sensors"></div>
  <div class="device-btns"></div>
  <div class="device-power"></div>
</div>

I hope this helps anyone else who's running into the same issue!

@aaarichter
Copy link

I ran into the same issue with https://github.com/picturepan2/devices.css/blob/master/src/_reset.scss#L3 setting display:block to every element. If you want to set markup inside the content this can break the content UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants