1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-24 11:16:27 +02:00
Files
csslayout/contents/fixed-at-side.md
2022-09-19 19:29:19 +07:00

41 lines
612 B
Markdown

---
layout: layouts/post.njk
title: Fixed at side
description: Fix an element at the middle of side with CSS
keywords: css fixed
---
## HTML
```html
<!-- Fixed at the middle of left side -->
<div class="fixed-at-side fixed-at-side--l">
...
</div>
<!-- Fixed at the middle of right side -->
<div class="fixed-at-side fixed-at-side--r">
...
</div>
```
## CSS
```css
.fixed-at-side {
position: fixed;
top: 50%;
transform: translate(0px, -50%);
}
.fixed-at-side--l {
left: 0;
}
.fixed-at-side--r {
right: 0;
}
```
{% demo %}
{% include "patterns/fixed-at-side.njk" %}
{% enddemo %}