Search This Blog

Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

2021/03/22

How to indent text exactly one character width

Set style as below:


padding-left: 1em:

text-indent: 1em;

margin: 0px

2020/04/08

Make a float button in your web page

No need to write JavaScript, just CSS and working in most popular browsers.

<style>
.floatButton {
  z-index: 1000;
  display: block;
  position: fixed;
  bottom: 120px;
  right: 120px;
}
</style>
<div class="floatButton"><button>float </button></div>

z-index: 1000; display: block; position: fixed; is important.

2016/11/28

CSS different child elements within a same parent同一阶层下的元素对应

HTML structure:
<div>
<span>element 1</span>
<p>element 2</p>
<p>element 3</p>
</div>

CSS:
div span {clear:both;}
div span + p {color: aquamarine;}
div span + p + p {color: blueviolet;}