Posts

Showing posts with the label Css

Convert HTML / CSS From Adobe XD

Answer : Adobe XD has a plugin ecosystem where you can download a third-party built plugin to achieve tasks not supported by Adobe XD itself. For web export, I can recommend a plugin called "Web Export." In order to use the plugin, Make sure you have the latest version of XD Go to Plugins > Discover Plugins > Search "Web Export" Click "Install" Hope this helps! Natively, you can't (yet), although some external plugins can help you achieve that. Adobe XD is a prototyping tool, ie it has been designed for producing the designs of websites and app before passing it to a developer that will "manually" build the HTML/CSS/JS out of it. However, the export to HTML/CSS/JS feature has been asked before by the community many times and the Adobe team is currently working on it (check this and this).

Can A Div Have Multiple Classes (Twitter Bootstrap)

Answer : Sure, a div can have as many classes as you want (this is both regarding to bootstrap and HTML in general): <div class="active dropdown-toggle"></div> Just separate the classes by space. Also: Keep in mind some bootstrap classes are supposed to be used for the same stuff but in different cases (for example alignment classes, you might want something aligned left, right or center, but it has to be only one of them) and you shouldn't use them together, or you'd get an unexpected result, basically what will happen is that the class with the highest specificity will be the one applied (or if they have the same then it'll be the one that's defined last on the CSS). So you better avoid doing stuff like this: <p class="text-center text-left">Some text</p> Absolutely, divs can have more than one class and with some Bootstrap components you'll often need to have multiple classes for them to function as you w...

Bootstrap Toast Does Not Show Up

Answer : You need to put the valid option. i:e show, hide or a callback function . See - https://getbootstrap.com/docs/4.2/components/toasts/. $('.toast').toast('show'); <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <div class="toast" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> <img height="200px" width="200px" src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Phoenicopterus_ruber_in_S%C3%A3o_Paulo_Zoo.jpg" class="rounded mr-2" alt="..."> <strong class="mr-auto">Boots...

Css Scrollbar-width Example

The scrollbar-width property allows the author to set the maximum thickness of an element’s scrollbars when they are shown. Initial value auto Applies to scrolling boxes Inherited no Computed value as specified Animation type discrete Syntax /* Keyword values */ scrollbar-width : auto ; scrollbar-width : thin ; scrollbar-width : none ; /* Global values */ scrollbar-width : inherit ; scrollbar-width : initial ; scrollbar-width : unset ; Values <scrollbar-width> Defines the width of the scrollbar as a keyword. It must be one of the following values: auto The default scrollbar width for the platform. thin A thin scrollbar width variant on platforms that provide that option, or a thinner scrollbar than the default platform scrollbar width. none No scrollbar shown, however the element will still be scrollable. Note : User Agents must apply any scrollbar-width value set on the root element to the viewport. Accessibility concerns Use this property with...

Adding Asterisk To Required Fields In Bootstrap 3

Answer : Use .form-group.required without the space. .form-group.required .control-label:after { content:"*"; color:red; } Edit: For the checkbox you can use the pseudo class :not(). You add the required * after each label unless it is a checkbox .form-group.required:not(.checkbox) .control-label:after, .form-group.required .text:after { /* change .text in whatever class of the text after the checkbox has */ content:"*"; color:red; } Note: not tested You should use the .text class or target it otherwise probably, try this html: <div class="form-group required"> <label class="col-md-2 control-label">&#160;</label> <div class="col-md-4"> <div class="checkbox"> <label class='text'> <!-- use this class --> <input class="" id="id_tos" name="tos" required="required" type=...

Css :first-of-type Example

The :first-of-type CSS pseudo-class represents the first element of its type among a group of sibling elements. /* Selects any <p> that is the first element of its type among its siblings */ p:first-of-type { color : red ; } Note : As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. Syntax :first-of-type Examples Styling the first paragraph HTML < h2 > Heading </ h2 > < p > Paragraph 1 </ p > < p > Paragraph 2 </ p > CSS p:first-of-type { color : red ; font-style : italic ; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector ( * ) is implied when no simple selector is written. HTML < article > < div > This `div` is first! </ div > < div > This < span > nested `span` is first </ span > ! </ div > < div > This < em > ...

Css :first-child Example

The :first-child CSS pseudo-class represents the first element among a group of sibling elements. /* Selects any <p> that is the first element among its siblings */ p:first-child { color : lime ; } Note : As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. Syntax :first-child Examples Basic example HTML < div > < p > This text is selected! </ p > < p > This text isn't selected. </ p > </ div > < div > < h2 > This text isn't selected: it's not a `p`. </ h2 > < p > This text isn't selected. </ p > </ div > CSS p:first-child { color : lime ; background-color : black ; padding : 5px ; } Result Styling a list HTML < ul > < li > Item 1 </ li > < li > Item 2 </ li > < li > Item 3 < ul > < li > Item 3.1 </ li > ...

Can I Apply A CSS Transition On Hover-out Only?

Answer : Here's one way to achieve this (put a bogus property none for transition property in :hover ): #inner2{ opacity:0; transition:opacity 2000ms; } #outer:hover #inner2{ opacity:1; transition:none; } http://jsfiddle.net/j716sbav/4/ Answer updated to incorporate @BoltClock's suggestion. Putting none instead of a bogus property is definitely more elegant. If you prefer not to specify the transition property more than once, you can apply the transition to :not(:hover) , but the caveat is that you need to swap all of the other declarations as well: #inner2{ opacity:1; } #outer:not(:hover) #inner2{ opacity:0; transition:opacity 2000ms; } Either of these will work, but if you don't want to deal with confusing inversions, stick with overriding via transition: none . Also note that CSS selectors represent states and not events, which means that it utilizes a :hover state rather than mouseover and mouseout events; however, a tra...

CSS Multiple Classes Property Override

Answer : As long as the selectors have the same specificity (in this case they do) and .myclass-right style block is defined after .myclass , yes. Edit to expand: the order the classes appear in the html element has no effect, the only thing that matters is the specificity of the selector and the order in which the selectors appear in the style sheet. Using !important is one way to do it. .myclass-right{ float:right !important; } In addition if you are more specific with your selector it should override as well div.myclass-right{ float:right; } Just wanted to throw out another option in addition to !important as well as style definition order: you can chain the two together as well: .myclass.myclass-right{float:right;} .myclass{float:left;}

Bring Element To Front Using CSS

Answer : Add z-index:-1 and position:relative to .content #header { background: url(http://placehold.it/420x160) center top no-repeat; } #header-inner { background: url(http://placekitten.com/150/200) right top no-repeat; } .logo-class { height: 128px; } .content { margin-left: auto; margin-right: auto; table-layout: fixed; border-collapse: collapse; z-index: -1; position:relative; } .td-main { text-align: center; padding: 80px 10px 80px 10px; border: 1px solid #A02422; background: #ABABAB; } <body> <div id="header"> <div id="header-inner"> <table class="content"> <col width="400px" /> <tr> <td> <table class="content"> <col width="400px" /> <tr> ...

CSS Text-decoration Underline Color

Answer : You can do it if you wrap your text into a span like: a { color: red; text-decoration: underline; } span { color: blue; text-decoration: none; } <a href="#"> <span>Text</span> </a> (for fellow googlers, copied from duplicate question) This answer is outdated since text-decoration-color is now supported by most modern browsers. You can do this via the following CSS rule as an example: text-decoration-color:green If this rule isn't supported by an older browser, you can use the following solution: Setting your word with a border-bottom: a:link { color: red; text-decoration: none; border-bottom: 1px solid blue; } a:hover { border-bottom-color: green; } As far as I know it's not possible... but you can try something like this: .underline { color: blue; border-bottom: 1px solid red; } <div> <span class="underline">hello world</span> </div>

Angular-material: Input-group And Md-buttons On Same Line

Answer : Try the following code: <form layout layout-align="center" layout-padding> <div layout="row" flex> <md-input-container flex class="md-icon-float md-block md-title"> <label>Your font number</label> <!-- below is the material icons --> <md-icon class="material-icons">phone</md-icon> <input type="text"> </md-input-container> <div> <md-button class="md-raised"> <!-- below is the material icons --> <md-icon class="material-icons">search</md-icon> </md-button> </div> </div> </form> see a sample in the following link http://codepen.io/cmwang-cottageclothing/pen/BjpdVQ?editors=1000 Would like to provide a contemporary answer to this popular question. 1...

Converting And Rendering Web Fonts To Base64 - Keep Original Look

Answer : In the Font Squirrel Expert options, make sure to set the 'TrueType Hinting' option to 'Keep Existing'. Either of the other options will cause the TrueType instructions (hints) to be modified, which will in turn affect the rendering of the font. Alternatively , if you're happy with the rendering of the font directly from GWF, you can just take that file and do the base64 encoding yourself. In OS X or Linux, use the built-in base64 command in Terminal/shell: $ base64 myfont.ttf > fontbase64.txt For Windows, you'll need to download a program to encode in base64 (there are several free/Open Source tools available). Copy the contents of that file, then use in your CSS as: @font-face { font-family: 'myfont'; src: url(data:font/truetype;charset=utf-8;base64,<<copied base64 string>>) format('truetype'); font-weight: normal; font-style: normal; } (Note that you may need to make some adjustments to the various @f...

Add CSS Rule Via JQuery For Future Created Elements

Answer : This should work: var style = $('<style>.class { background-color: blue; }</style>'); $('html > head').append(style); When you plan to remove elements from the DOM to re-insert them later, then use .detach() instead of .remove() . Using .detach() will preserve your CSS when re-inserting later. From the documentation: The .detach() method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time. Here is some JavaScript code I wrote before to let me add, remove and edit CSS: function CSS(sheet) { if (sheet.constructor.name === 'CSSStyleSheet' ) this.sheet = sheet; else if (sheet.constructor.name === 'HTMLStyleElement') this.sheet = sheet.sheet; else throw new TypeError(sheet + ' is not a StyleSheet'); } CSS.prototype = {...

Bootstrap Row With Columns Of Different Height

Image
Answer : This is a popular Bootstrap question, so I've updated and expanded the answer for Bootstrap 3 and Bootstrap 4... The Bootstrap 3 "height problem" occurs because the columns use float:left . When a column is “floated” it’s taken out of the normal flow of the document. It is shifted to the left or right until it touches the edge of its containing box. So, when you have uneven column heights , the correct behavior is to stack them to the closest side. Note : The options below are applicable for column wrapping scenarios where there are more than 12 col units in a single .row . For readers that don't understand why there would ever be more than 12 cols in a row , or think the solution is to "use separate rows" should read this first There are a few ways to fix this.. (updated for 2018) 1 - The 'clearfix' approach (recommended by Bootstrap) like this (requires iteration every X columns). This will force a wrap every X number...

Bottom Border On Bootstrap Row

Answer : You could do this with a pseudo element with left and right margin to overcome the padding issue: @import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; .row-bordered:after { content: ""; display: block; border-bottom: 1px solid #ccc; margin: 0 15px; } <div class="container"> <div class="row row-bordered"> <div class="col-xs-10"> Heading Text </div> <div class="col-xs-2 text-right"> <a href="#"><span class="glyphicon glyphicon-pencil"></span></a> <a href="#"><span class="glyphicon glyphicon-trash"></span></a> </div> </div> </div> The solution above longer works in Bootstrap 4 due to switching to Flexbox, but a few modifications fixes it: .row-bordered { position: relative; } .row-bordered:after...

CSS: How To Have Position:absolute Div Inside A Position:relative Div Not Be Cropped By An Overflow:hidden On A Container

Image
Answer : A trick that works is to position box #2 with position: absolute instead of position: relative . We usually put a position: relative on an outer box (here box #2) when we want an inner box (here box #3) with position: absolute to be positioned relative to the outer box. But remember: for box #3 to be positioned relative to box #2, box #2 just need to be positioned. With this change, we get: And here is the full code with this change: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <style type="text/css"> /* Positioning */ #box1 { overflow: hidden } #box2 { position: absolute } #box3 { position: absolute; top: 10px } /* Styling */ #box1 { background: #efe; padding: 5px; width: 125px } #box2 { background: #fee; padding: 2px; width: 100px; height: 100px } #box3 { background: #eef; pad...

CSS Selector For Child Of Parent's Sibling Element

Answer : In a word: no. Given the current structure of your HTML (and the current state of CSS selectors), this is not possible. Perhaps we will get something like this in CSS4, but traversal like this is best left up to Javascript. You can obviously restructure your markup, and use the sibling selector: HTML <div class="parent"> <a href="#" id="trigger">Trigger</a> <div class="sibling"> <div id="change">Hello</div> </div> </div> CSS #trigger:hover + .sibling #change { color:red; } codepen No. You cannot achieve this using CSS only. Javascript is a good option in this case.. You can however detect the .parent being hovered (which will solve your problem if the parent surrounds exactly the trigger): .parent:hover + .sibling div#change{background:red;} (markup stays the same jsFiddle)

Angular: Conditional Class With *ngClass

Answer : Angular version 2+ provides several ways to add classes conditionally: type one [class.my-class]="step === 'step1'" type two [ngClass]="{'my-class': step === 'step1'}" and multiple option: [ngClass]="{'my-class': step === 'step1', 'my-class2':step === 'step2' }" type three [ngClass]="{1:'my-class1',2:'my-class2',3:'my-class4'}[step]" type four [ngClass]="(step=='step1')?'my-class1':'my-class2'" [ngClass]=... instead of *ngClass . * is only for the shorthand syntax for structural directives where you can for example use <div *ngFor="let item of items">{{item}}</div> instead of the longer equivalent version <template ngFor let-item [ngForOf]="items"> <div>{{item}}</div> </template> See also https://angular.io/docs/ts/latest/api/common/index/NgCl...

CSS Image Overlay With Color And Transparency

Answer : CSS Filter Effects It's not fully cross-browsers solution, but must work well in most modern browser. <img src="image.jpg" /> <style> img:hover { /* Ch 23+, Saf 6.0+, BB 10.0+ */ -webkit-filter: hue-rotate(240deg) saturate(3.3) grayscale(50%); /* FF 35+ */ filter: hue-rotate(240deg) saturate(3.3) grayscale(50%); } </style> EXTERNAL DEMO PLAYGROUND CSS Filter Effects IN-HOUSE DEMO SNIPPET (source:simpl.info) #container { text-align: center; } .blur { filter: blur(5px) } .grayscale { filter: grayscale(1) } .saturate { filter: saturate(5) } .sepia { filter: sepia(1) } .multi { filter: blur(4px) invert(1) opacity(0.5) } <div id="container"> <h1><a href="https://simpl.info/cssfilters/" title="simpl.info home page">simpl.info</a> CSS filters</h1> <img src="https://simpl.info/cssfilters/balham.jpg" alt="No filter: B...