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

::before pseudo element with display:block stops balancing #150

Open
christianmagill opened this issue Mar 29, 2022 · 3 comments
Open

::before pseudo element with display:block stops balancing #150

christianmagill opened this issue Mar 29, 2022 · 3 comments

Comments

@christianmagill
Copy link

christianmagill commented Mar 29, 2022

Original Title: ::before pseudo element used as accent stops balancing.

Expected Behaviour

I'd like to use graphical accents for a number of headlines. If I add these using a ::before pseudo-element, I'd like the text to continue to balance.

Actual Behaviour

When I include a ::before pseudo-element as an accent, the text is not balanced.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

3.3.0 / Testing on Chrome (Mac OS)

Sample Code that illustrates the problem

h2::before {
  content: "";
  display: block;
  background: url("images/graphic-wave.png");
  background-size: contain;
  width: 100px;
  height: 26px;
  margin-bottom: 32px;
}

balanceText('h2', {watch: true});

Logs taken while reproducing problem

@redmunds
Copy link
Contributor

redmunds commented Mar 30, 2022

@christianmagill Thanks for logging bugs. I haven't had a chance to look at this yet, but display:block seems problematic. This code was designed to balance inline content inside a block-level container, so I'm wondering if pseudo-element may be removed from the context. Have you tried removing display:block (which I think defaults to display:inline)?

@christianmagill
Copy link
Author

I couldn't get display:inline to work as needed, but what I ended up doing was adding the background image to the h2 and adding padding to compensate.

@redmunds redmunds changed the title ::before psuedo element used as accent stops balancing. ::before pseudo element used as accent stops balancing. Apr 1, 2022
@redmunds
Copy link
Contributor

redmunds commented Apr 1, 2022

Glad to hear that you found a workaround.

Currently in the code, el.offsetWidth for element with ::before pseudo-element is 0, so code thinks there is no text to balance. Not sure how to fix this off the top-of-my-head. I will leave this issue open in case anyone has any ideas about this.

@redmunds redmunds changed the title ::before pseudo element used as accent stops balancing. ::before pseudo element with display:block stops balancing Apr 21, 2022
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

2 participants