Categories
CSS

How to remove page title and date when printing web page with CSS?

Sometimes, we want to remove page title and date when printing web page with CSS.

In this article, we’ll look at how to remove page title and date when printing web page with CSS.

How to remove page title and date when printing web page with CSS?

To remove page title and date when printing web page with CSS, we can use the @page rule.

For instance, we write

@page {
  size: auto;
  margin: 0mm;
}

to set the margin to 0mm to hide the page title.

The title is printed at the margin so setting the margin to 0mm would hide the title.

Conclusion

To remove page title and date when printing web page with CSS, we can use the @page rule.

Categories
CSS

How to force HTML table row on a single line with CSS?

Sometimes, we want to force HTML table row on a single line with CSS.

In this article, we’ll look at how to force HTML table row on a single line with CSS.

How to force HTML table row on a single line with CSS?

To force HTML table row on a single line with CSS, we use the table-layout: fixed property.

For instance, we write

table {
  table-layout: fixed;
}
td {
  overflow: hidden;
  white-space: nowrap;
}

to set table-layout to fixed to make the table cells’ widths fixed.

Then we use overflow: hidden; and white-space: nowrap; on the td elements to keep the cell content in 1 line and hide any overflow text.

Conclusion

To force HTML table row on a single line with CSS, we use the table-layout: fixed property.

Categories
CSS

How to invert colors of an image in CSS?

Sometimes, we want to invert colors of an image in CSS.

In this article, we’ll look at how to invert colors of an image in CSS.

How to invert colors of an image in CSS?

To invert colors of an image in CSS, we can use the invert CSS filter.

For instance, we write

<img src="https://picsum.photos/200/300" />

to add an image.

Then we write

img {
  -webkit-filter: invert(1);
  filter: invert(1);
}

to use the invert filter to invert the colors in an image.

Conclusion

To invert colors of an image in CSS, we can use the invert CSS filter.

Categories
CSS

How to make div fixed scrolling to that div with CSS?

Sometimes, we want to make div fixed scrolling to that div with CSS.

In this article, we’ll look at how to make div fixed scrolling to that div with CSS.

How to make div fixed scrolling to that div with CSS?

To make div fixed scrolling to that div with CSS, we can use the position: sticky CSS property.

For instance, we write

position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 1;

to set position to sticky and z-index to 1 to make the element with the sticky position show on top after we scroll to it.

Conclusion

To make div fixed scrolling to that div with CSS, we can use the position: sticky CSS property.

Categories
CSS

How to remove or disable focus border of browser with CSS?

Sometimes, we want to remove or disable focus border of browser with CSS.

In this article, we’ll look at how to remove or disable focus border of browser with CSS.

How to remove or disable focus border of browser with CSS?

To remove or disable focus border of browser with CSS, we select the styles for the :focus pseudo-class.

For instance, we write

:focus {
  outline: none;
}

to set the outline style to none to remove the border of the element that’s in focus.

Conclusion

To remove or disable focus border of browser with CSS, we select the styles for the :focus pseudo-class.