{"id":11470,"date":"2022-01-27T10:00:00","date_gmt":"2022-01-27T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11470"},"modified":"2022-01-27T10:18:07","modified_gmt":"2022-01-27T01:18:07","slug":"css-tricks-for-web-designer","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11470","title":{"rendered":"CSS tricks for web designer"},"content":{"rendered":"\n<p><strong>&#8212; Absolute positioning<\/strong><\/p>\n\n\n\n<p>If you want to define where an element is placed on the website at all times, absolute positioning is the key to make this happen.&nbsp;Absolute positioning allows you to control exactly where an element will stay. And then&nbsp;use top, right, bottom and left, accompanied by a pixel value to control the place.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>position:absolute;\nbottom:10px;\nright:10px<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>The CSS above sets the position of an element to stay 10px from the bottom and right edges of the browser.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; Use a CSS preprocessor<\/strong><\/p>\n\n\n\n<p>Use Less or Sass or SCSS when you develop the website. They can help you declare colors, sizes, etc one single time, and create CSS with for cycles and similar things.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; Link states<\/strong><\/p>\n\n\n\n<p>The&nbsp;<em>:link<\/em>&nbsp;pseudo-class controls all links that haven\u2019t been clicked on yet. The&nbsp;<em>:visited<\/em>&nbsp;pseudo class handles the styling of all of the links you\u2019ve already visited. This tells website visitors where they have already been on the site, and where they have yet to explore.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a:link { color: blue; }\na:visited { color: purple; }<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; Resize images to fit<\/strong><\/p>\n\n\n\n<p>Sometimes  images are needed to fit a certain width, while scaling proportionally. An easy way to do this is to use max width to handle this. <\/p>\n\n\n\n<p>Here is an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img {\n    max-width:100%;\n    height:auto;\n}<\/code><\/pre>\n\n\n\n<p><strong>&#8212; Split HTML and CSS<\/strong><\/p>\n\n\n\n<p>It is the best idea of <strong>creating different CSS files<\/strong>&nbsp;(for example, one for desktop and one for mobile) while developing, and only, in the end, merge them.<\/p>\n\n\n\n<p>The same principle can be made with HTML. If you\u2019re not developing in SPA environments, you can use PHP to include and require pieces of HTML code.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; Direct children<\/strong><\/p>\n\n\n\n<p>Use&nbsp;<em>&gt;<\/em>&nbsp;to select the direct children of an element. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#footer &gt; a<\/code><\/pre>\n\n\n\n<p>This will select and style all of the active link elements that are immediately under the Footer ID.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; &nbsp;:before<\/strong><\/p>\n\n\n\n<p>This CSS is a selector that allows you to choose a CSS element and insert content before every element with a specific class applied to it.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>h3:before { \n    content: \"More: \";\n&lt;span class=\"new-blog\"&gt; color: #F00;&lt;\/span&gt;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>&#8212; :after<\/strong><\/p>\n\n\n\n<p>Like the :before selector,  :after can be used to insert content globally on specific elements. A practical use would be adding \u201csee more\u201d after every excerpt on an article . You can do like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p:after{ \n    content: \" -Read more\u2026 \";\n    color:#f00;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>By Tsuki<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11470\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11470\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"CSS tricks for web designer\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11470\" data-text=\"CSS tricks for web designer\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11470\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11470\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>&#8212; Absolute positioning If you want to define where an element is placed on the website at all times, abs [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11470"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11470"}],"version-history":[{"count":12,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11470\/revisions"}],"predecessor-version":[{"id":11496,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11470\/revisions\/11496"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}