question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

position:absolute not working on lit-element

See original GitHub issue

More of a help question, I’m probably doing something wrong here:

@customElement('my-input')
class myInput extends LitElement {
  static get styles() {
    return css`
      :host {
        display:contents;
      }
      input {
        all:inherit;
        display:inline;
      }
      .link {
        position:absolute;
        right:0px;
        top:50%;
      }
    `
  }
  render() {
    return html`
      <input></input>
      <span class=link>content</span>
    `
  }
}

I would expect content to be placed inside the input on the right side, instead it is placed relative to the parent element. If I place the <span> inside the <input> element the same happens. This is not the behavior I would expect, what is going on here?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
justinfagnanicommented, Mar 15, 2021

Attributes values don’t have to be quoted in HTML unless they contain a whitespace, >, <, =, or a quote.

0reactions
sorvellcommented, Jan 15, 2022

Closing based on the discussion above. These are limitations of css in general and there’s nothing to address in the Lit library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

position:absolute not working on lit-element #1173 - GitHub
position : absolute elements are positioned wrt their offset parent, which is the closest position: relative ancestor. You'll need position: ...
Read more >
LitElement: drag and drop absolute positioned items inside a ...
The items are positioned absolute , the outer container is positioned relative . Code looks like this: static get styles(): CSSResult { return ......
Read more >
Why is position not working?. Guide to CSS positions - Medium
The absolute position exiles the element from natural flow. All you are left now with are tricks. For instance, centring horizontally. margin: ...
Read more >
Built-in directives - Lit.dev
Directive, Summary. Styling. classMap. Assigns a list of classes to an element based on an object. styleMap. Sets a list of style properties...
Read more >
Lit Element With Gql And Ts (forked) - StackBlitz
Lit-element demo base project with typescript. ... @customElement("not-link"). export class NotLink extends LitElement { ... position: absolute;. bottom: 0;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found