mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-23 18:56:29 +02:00
69 lines
1.1 KiB
Markdown
69 lines
1.1 KiB
Markdown
---
|
|
layout: layouts/post.njk
|
|
title: Fixed at corner
|
|
description: Fix an element at corner with CSS
|
|
keywords: css fixed
|
|
---
|
|
|
|
## HTML
|
|
|
|
```html
|
|
<div class="fixed-at-corner">
|
|
<!-- Top-left corner -->
|
|
<div class="fixed-at-corner__corner fixed-at-corner__corner--tl">
|
|
...
|
|
</div>
|
|
|
|
<!-- Top-right corner -->
|
|
<div class="fixed-at-corner__corner fixed-at-corner__corner--tr">
|
|
...
|
|
</div>
|
|
|
|
<!-- Bottom-right corner -->
|
|
<div class="fixed-at-corner__corner fixed-at-corner__corner--br">
|
|
...
|
|
</div>
|
|
|
|
<!-- Bottom-left corner -->
|
|
<div class="fixed-at-corner__corner fixed-at-corner__corner--bl">
|
|
...
|
|
</div>
|
|
</div>
|
|
```
|
|
|
|
## CSS
|
|
|
|
```css
|
|
.fixed-at-corner {
|
|
position: relative;
|
|
}
|
|
|
|
.fixed-at-corner__corner {
|
|
position: absolute;
|
|
}
|
|
|
|
.fixed-at-corner__corner--tl {
|
|
left: 0;
|
|
top: 0;
|
|
}
|
|
|
|
.fixed-at-corner__corner--tr {
|
|
top: 0;
|
|
right: 0;
|
|
}
|
|
|
|
.fixed-at-corner__corner--br {
|
|
bottom: 0;
|
|
right: 0;
|
|
}
|
|
|
|
.fixed-at-corner__corner--bl {
|
|
bottom: 0;
|
|
left: 0;
|
|
}
|
|
```
|
|
|
|
{% demo %}
|
|
{% include "covers/fixed-at-corner.njk" %}
|
|
{% enddemo %}
|