Jump to content

Search the Community

Showing results for tags 'css'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • SD Official
  • Web Scripts
  • Themes & Templates
  • Software
  • Marketing
  • Social Media
  • Business
  • Servers
  • Security
  • Mobile

Categories

  • Storm Developers
  • Code
    • PHP
    • CSS
  • Web Design
  • Databases
  • Web Scripts
  • Software
  • Marketing & SEO
  • Social Media
  • Business
  • Photo & Video
  • 3D & Motion Graphics
  • Game Development

Categories

  • Website Issues
  • Themes & Templates
    • IPS Themes
  • Addons & Plugins
    • IPS Plugins
  • Storm ERP
    • Code Problems
    • Design Problems
  • SimplePHPFramework

Categories

  • Website Feature Requests
  • Themes & Templates
    • IPS Themes
  • Addons & Plugins
    • IPS Plugins
  • StormERP Requests
  • SimplePHPFramework Requests

Categories

  • Content & Articles
  • Marketing & SEO
  • Website Staff / Team
  • Feedback & Reviews
  • Graphics & Desgin
  • Misc - Other Offers

Product Groups

  • Services
    • Installations & Setups
  • Advertisements
    • Sidebar Advertising
    • Topic Advertising
    • Post Advertising
    • Footer Advertising
  • Licenses
  • Copyright Removal
  • Book Work Hours
  • Community Currency
    • User Activity Points
    • Storm Developers Coin
  • Web Hosting
  • Merchandise

Forums

  • SD Core
    • Community Hub
    • SD Themes Support
    • SD Extensions, Addons & Plugins Support
    • SD Software Support
  • WebMaster Zone
    • Managing a Website
    • Managing a Community
    • Servers & Hosting
    • Generating Revenue
    • Security & Legal
  • Developers & Coding
    • Coding & Development Help
    • Coding Languages
    • Databases & Data Storage
    • PHP Frameworks
    • IDEs & Tools
  • Marketing & Social Media
    • General Marketing
    • Social Media
    • SEO & SEM
    • Affiliate Marketing
    • CPA Marketing
  • Web Software Zone
    • Forum Software
    • CMS & CMF Software
    • eCommerce
    • CRM & ERP
    • Blog & Wikis
    • Billing & Invoicing
    • Social Platforms
  • Operating System Software
    • General OS Talk
    • Web Browsers
  • Designers Corner
    • Designers Talk
    • Designers Help
    • Themes & Templates Talk
    • Designers Applications & Software
  • Storm Developers Official's Topics

Categories

  • Storm Developers Official
    • Web Scripts
    • Themes & Templates
    • Addons & Plugins
  • Web Scripts
    • PHP Scripts
    • Python WebScripts
    • ASP & ASP.NET
    • Ajax
    • Javascript
  • Themes & Templates
    • HTML / HTML5
    • Ecommerce
    • CMS
    • Forums
  • Software
    • Windows Software
    • MacOS
    • Linux
  • Addons
    • CMS Addons
    • Forum Addons
    • Ecommerce Addons
  • Ebooks
    • Marketing Ebooks
    • Social Media
    • Business
    • Earn Online

Calendars

  • Community Calendar
  • Software Events

Blogs

There are no results to display.

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Gender


Location


Website


Github

Found 3 results

  1. If you’ve done any complex web UI development, you must have at least once furiously tried driving an element’s z-index up to thousands, only to see that it’s not helping position it on top of some other element, whose z-index is lower or even not defined at all. Why does that happen? And more importantly, how to avoid such issues? In this article, I’ll recap what z-index actually is and how you can stop guessing whether it might work in any specific case and start treating it just like any other convenient tool. The Hierarchy Of Stacking Contexts If you imagine the webpage as having three dimensions, then z-index is a property that defines the z coordinate of an element (also called its “stacking order”): the larger the value, the closer the element is to the observer. You can also think of it as a property affecting paint order, and this will in fact be more correct since the screen is a two-dimensional grid of pixels. So, the larger the z-index value, the later the element is painted on the page. There is, however, one major complication. The z-index value space is not flat — it’s hierarchical. An element can create a stacking context which becomes the root for z-index values of its descendants. It would be best to explain the concept of stacking contexts by using an example. The document body has five div descendants: div1, div2, div3, div1-1, and div2-1. They’re all absolutely positioned and overlap with each other. div1-1 is a child of div1, and div2-1 is a child of div2. See the Pen stacking-contexts by Pavel Pomerantsev. Let’s try to understand why we see what we see. There are quite elaborate rules to determine paint order, but here we only need to compare two things: z-index Values If an element has a higher z-index, it’s painted later. Source Order If z-index values are the same, then the later it’s in the source, the later it’s painted. So if we don’t take stacking contexts into account, the order should be as follows: div1 div2 div3 div1-1 div2-1 Note that div2-1 is in fact overlapped by div3. Why is that happening? If an element is said to create a stacking context, it creates a basis for its children’s z-index values, so they’re never compared with anything outside the stacking context when determining paint order. To put it another way, when an element creating a stacking context is painted, all its children are painted right after it and before any of its siblings. Going back to the example, the actual paint order of body’s descendant divs is: div1 div2 div3 div1-1 Notice the absence of div2-1 in the list — it’s a child of div2 which creates a stacking context (because it’s an absolutely positioned element with a z-index other than the default value of auto), so it’s painted after div2, but before div3. div1 doesn’t create a stacking context, because its implicit z-index value is auto, so div1-1 (its child) is painted after div2 and div3 (since its z-index, 10, is larger than that of div2 and div3). Don’t worry if you didn’t fully grasp this on first reading. There’s a bunch of online resources that do a great job in explaining these concepts in more detail: “The Stacking Context,” MDN web docs, Mozilla “What No One Told You About Z-Index,” Philip Walton Note: It’s also great to be familiar with general paint order rules (which are actually quite complex). The main point of this piece, however, is how to deal with z-index when your page is composed of dozens and hundreds of components, each potentially having children with z-index defined. One of the most popular articles on z-index proposes grouping all z-index values in one place, but comparing those values doesn’t make sense if they don’t belong to the same stacking context (which might not be easy to achieve in a large application). Here’s an example. Let’s say we have a page with header and main sections. The main section for some reason has to have position: relative and z-index: 1. See the Pen z-index-step1 by Pavel Pomerantsev. We’re using a component architecture here, so CSS for the root component and every child component is defined in dedicated sections. In practice, components would live in separate files, and the markup would be generated using a JavaScript library of your choice, like React, but for demonstration purposes it’s fine to have everything together. Now, imagine we’re tasked with creating a dropdown menu in the header. It has to be stacked on top of the main section, of course, so we’ll give it a z-index of 10: See the Pen z-index-step2 by Pavel Pomerantsev. Now, a few months later, in order to make something unrelated work better, we apply the translateZ hack to the header. See the Pen z-index-step3 by Pavel Pomerantsev. As you can see, the layout is now broken. An element with z-index: 1 sits on top of an element with z-index: 10, in the absence of any other z-index rules. The reason is that the header now creates a stacking context — it’s an element with a transform property whose value is anything other than none (see full rules) and its own z-index (0 by default) is lower than that of the main section (1). The solution is straightforward: give the header a z-index value of 2, and it’ll be fixed. See the Pen z-index-step4 by Pavel Pomerantsev. The question is, how are we supposed to come to this solution if we have components within components within components, each having elements with different z-indices? How can we be sure that changing z-index of the header won’t break anything else? The answer is a convention that eliminates the need for guesswork, and it’s the following: changing z-indices within a component should only affect that component, and nothing else. To put it differently, when dealing with z-index values in a certain CSS file, we should ideally only concern ourselves with other values in that same file. Achieving it is easy. We should simply make sure that the root of every component creates a stacking context. The easiest way to do it is to give it position and z-index values other than the default ones (which are static and auto, respectively). Here’s one of the ways to structure the application. It uses more elements than the previous one, but computation associated with extra DOM elements is cheap whereas developer’s time (a lot of which can sometimes be spent on debugging stacking issues) is definitely not. See the Pen z-index-step5 by Pavel Pomerantsev. header__container and main__container both have position: relative and z-index: 0; header__overlay now has z-index: 1 (we don’t need a large value since it’s only going to compete for stacking order with other elements within the header); root__header now has z-index: 2, whereas root__main keeps its z-index: 1, and this is what makes the two siblings stack correctly. (Note also that both have position: relative since z-index doesn’t apply to statically positioned elements.) If we look at the header code now, we’ll notice that we can remove the z-index property from both the container and the overlay altogether because the overlay is the only positioned element there. Likewise, the z-index is not required on the main container. This is the biggest benefit of the proposed approach: when looking at z-indices, it’s only the component itself that matters, not its context. See the Pen z-index-step6 by Pavel Pomerantsev. Such an architecture is not without its drawbacks. It makes the application more predictable at the expense of some flexibility. For example, you won’t be able to create such overlays inside both the header and the main section: See the Pen z-index-step7 by Pavel Pomerantsev. In my experience, however, this is rarely a problem. You could make the overlay in the main section go down instead of up, in order for it to not intersect with the header. Or, if you really needed it to go up, you could inject the overlay HTML at the end of the body and give it a large z-index (“large” being whatever’s larger than those of other sections at the top level). In any case, if you’re not in a competition to build the most complicated layout, you should be fine. To recap: Isolate components in terms of z-index values of elements by making the root of each component a stacking context; You don’t have to do it if no element within a component needs a z-index value other than auto; Within a component’s CSS file, maintain z-index values any way you like. It might be consecutive values, or you could give them a step of 10, or you can use variables — it all depends on your project’s conventions and the size of the component (although making components smaller is never a bad thing). Preferably, only assign z-index to sibling elements. Otherwise, you may inadvertently introduce more stacking contexts within a component, and you’re faced with the same issue again, luckily on a smaller scale; Debugging becomes easy. Find the first ancestor component of the two elements that are not stacked correctly, and change z-indices within that component as necessary. This approach will hopefully bring back some sanity to your development process.
  2. We have a whole selection of ways to align things in CSS today, and it isn’t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a particular alignment problem. In this article, I will take a look at the different alignment methods. Instead of providing a comprehensive guide to each, I’ll explain a few of the sticking points people have and point to more complete references for the properties and values. As with much of CSS, you can go a long way by understanding the fundamental things about how the methods behave, and then need a place to go look up the finer details in terms of how you achieve the precise layout that you want. Aligning Text And Inline Elements When we have some text and other inline elements on a page, each line of content is treated as a line box. The property text-align will align that content on the page, for example, if you want your text centered, or justified. Sometimes, however, you may want to align things inside that line box against other things, for example, if you have an icon displayed alongside text, or text of different sizes. In the example below, I have some text with a larger inline image. I am using vertical-align: middle on the image to align the text to the middle of the image. See the Pen Vertical Alignment example by Rachel Andrew. The line-height Property And Alignment Remember that the line-height property will change the size of the line-box and therefore can change your alignment. The following example uses a large line-height value of 150px, and I have aligned the image to top. The image is aligned to the top of the line box and not the top of the text, remove that line-height or make it less than the size of the image and the image and text will line up at the top of the text. See the Pen Vertical Alignment and line-height by Rachel Andrew. It turns out that line-height and indeed the size of text is pretty complicated, and I’m not going to head down that rabbit hole in this article. If you are trying to precisely align inline elements and want to really understand what is going on, I recommend reading “Deep Dive CSS: Font Metrics, line-height And vertical-align.” When Can I Use The vertical-align Property? The vertical-align property is useful if you are aligning any inline element. This includes elements with display: inline-block. The content of table cells can also be aligned with the vertical-align property. The vertical-align property has no effect on flex or grid items, and therefore if used as part of a fallback strategy, will cease to apply the minute the parent element is turned into a grid or flex Container. For example, in the next pen, I have a set of items laid out with display: inline-block and this means that I get the ability to align the items even if the browser does not have Flexbox: See the Pen inline-block and vertical-align by Rachel Andrew. In this next pen, I have treated the inline-block as a fallback for Flex layout. The alignment properties no longer apply, and I can add align-items to align the items in Flexbox. You can tell that the Flexbox method is in play because the gap between items that you will get when using display: inline-block is gone. See the Pen inline-block flex fallback by Rachel Andrew. The fact that vertical-align works on table cells is the reason that the trick to vertically center an item using display: table-cell works. Now that we do have better ways to align boxes in CSS (as we will look at in the next section), we don’t need to employ the vertical-align and text-align properties in places other than the inline and text elements for which they were designed. However, they are still completely valid to use in those text and inline formats, and so remember if you are trying to align something inline, it is these properties and not the Box Alignment ones that you need to reach for. Box Alignment The Box Alignment Specification deals with how we align everything else. The specification details the following alignment properties: justify-content align-content justify-self align-self justify-items align-items You might already think of these properties as being part of the Flexbox Specification, or perhaps Grid. The history of the properties is that they originated as part of Flexbox, and still exist in the Level 1 specification; however, they were moved into their own specification when it became apparent that they were more generally useful. We now also use them in Grid Layout, and they are specified for other layout methods too, although current browser support means that you won’t be able to use them just yet. Therefore, next time someone on the Internet tells you that vertical alignment is the hardest part of CSS, you can tell them this (which even fits into a tweet): .container { display: flex; align-items: center; justify-content: center; } In the future, we may even be able to dispense with display: flex, once the Box Alignment properties are implemented for Block Layout. At the moment, however, making the parent of the thing you want centering a flex container is the way to get alignment horizontally and vertically. The Two Types Of Alignment When aligning flex and grid items, you have two possible things to align: You have the spare space in the grid or flex container (once the items or tracks have been laid out). You also have the item itself inside the grid area you placed it in, or on the cross axis inside the flex container. I showed you a set of properties above, and the alignment properties can be thought of as two groups. Those which deal with distribution of spare space, and those which align the item itself. Dealing With Spare Space: align-content And justify-content The properties which end in -content are about space distribution, so when you choose to use align-content or justify-content you are distributing available space between grid tracks or flex items. They don’t change the size of the flex or grid items themselves; they move them around because they change where the spare space goes. Below, I have a flex example and a grid example. Both have a container which is larger than required to display the flex items or grid tracks, so I can use align-content and justify-content to distribute that space. See the Pen justify-content and align-content by Rachel Andrew. Moving Items Around: justify-self, align-self, justify-items And align-items We then have align-self and justify-self as applied to individual flex or grid items; you can also use align-items and justify-items on the container to set all the properties at once. These properties deal with the actual flex or grid item, i.e. moving the content around inside the Grid Area or flex line. Grid Layout You get both properties as you can shift the item on the block and inline axis as we have a defined Grid Area in which it sits. Flex Layout You can only align on the cross axis as the main axis is controlled by space distribution alone. So if your items are a row, you can use align-self to shift them up and down inside the flex line, aligning them against each other. In my example below, I have a flex and a grid container, and am using align-items and align-self in Flexbox to move the items up and down against each other on the cross axis. If you use Firefox, and inspect the element using the Firefox Flexbox Inspector, you can see the size of the flex container and how the items are being moved vertically inside of that. Aligned flex items with the flex container highlighted in Firefox (Large preview) In grid, I can use all four properties to move the items around inside their grid area. Once again, the Firefox DevTools Grid Inspector will be useful when playing with alignment. With the grid lines overlaid, you can see the area inside which the content is being moved: Aligned grid items with the Grid highlighted in Firefox (Large preview) Play around with the values in the CodePen demo to see how you can shift content around in each layout method: See the Pen justify-self, align-self, justify-items, align-items by Rachel Andrew. Confused By align And justify One of the cited issues with people remembering the alignment properties in Grid and Flexbox, is that no one can remember whether to align or to justify. Which direction is which? For Grid Layout, you need to know if you are aligning in the Block or Inline Direction. The Block direction is the direction blocks lay out on your page (in your writing mode), i.e. for English that is vertically. The Inline direction is the direction in which sentences run (so for English that is left to right horizontally). To align things in the Block Direction, you will use the properties which start with align-. You use align-content to distribute space between grid tracks, if there is free space in the grid container, and align-items or align-self to move an item around inside the grid area it has been placed in. The below example has two grid layouts. One has writing-mode: horizontal-tb (which is the default for English) and the other writing-mode: vertical-rl. This is the only difference between them. You can see that the alignment properties which I have applied work in exactly the same way on the block axis in both modes. See the Pen Grid Block Axis Alignment by Rachel Andrew. To align things in the inline direction, use the properties which begin with justify-. Use justify-content to distribute space between grid tracks, and justify-items or justify-self to align items inside their grid area in the inline direction. Once again, I have two grid layout examples so that you can see that inline is always inline — no matter which writing mode you are using. See the Pen Grid Inline Alignment by Rachel Andrew. Flexbox is a little trickier due to the fact that we have a main axis which can be changed to row or column. So, let’s first think about that main axis. It is set with the flex-direction property. The initial (or default) value of this property is row which will lay the flex items out as a row in the writing mode currently in use — this is why when working in English, we end up with items laid out horizontally when we create a flex container. You can then change the main axis to flex-direction: column and the items will be laid out as a column which means they are laid out in the block direction for that writing mode. As we can do this axis switching, the most important factor in Flexbox is asking, “Which axis is my main axis?” Once you know that, then for alignment (when on your main axis) you simply use justify-content. It doesn’t matter if your main axis is row or column. You control space between the flex items with justify-content. See the Pen justfy-content in Flexbox by Rachel Andrew. On the cross axis, you can use align-items which will align the items inside the flex container or flex line in a multi-line flex container. If you have a multi-line container using flex-wrap: wrap and have space in that container, you can use align-content to distribute the space on the cross axis. In the example below, we are doing both with a flex container displayed as a row and a column: See the Pen Cross axis alignment in Flexbox by Rachel Andrew. When justify-content Or align-content Do Not Work The justify-content and align-content properties in Grid and Flexbox are about distributing extra space. So the thing to check is that you have extra space. Here is a Flex example: I have set flex-direction: row and I have three items. They don’t take up all of the space in the flex container, so I have spare space on the main axis, the initial value for justify-content is flex-start and so my items all line up at the start and the extra space is at the end. I am using the Firefox Flex Inspector to highlight the space. The spare space at the end of the container (Large preview) If I change flex-direction to space-between, that extra space is now distributed between the items: The spare space is now between the items (Large preview) If I now add more content to my items so they become larger and there is no longer any additional space, then justify-content does nothing — simply because there is no space to distribute. There is now no space to distribute (Large preview) A common question I’m asked is why justify-content isn’t working when flex-direction is column. This is generally because there is no space to distribute. If you take the above example and make it flex-direction: column, the items will display as a column, but there will be no additional space below the items as there is when you do flex-direction: row. This is because when you make a Flex Container with display: flex you have a block level flex container; this will take up all possible space in the inline direction. In CSS, things do not stretch in the block direction, so no extra space. The column is only as tall as needed to display the items (Large preview) Add a height to the container and — as long as that is more than is required to display the items — you have extra space and therefore justify-content will work on your column. Adding a height to the container means we have spare space (Large preview) Why Is There No justify-self In Flexbox? Grid Layout implements all of the properties for both axes because we always have two axes to deal with in Grid Layout. We create tracks (which may leave additional space in the grid container in either dimension,) and so we can distribute that space with align-content or justify-content. We also have Grid Areas, and the element in that area may not take up the full space of the area, so we can use align-self or justify-self to move the content around the area (or align-items, justify-items to change the alignment of all items). Flexbox does not have tracks in the way that Grid layout does. On the main axis, all we have to play with is the distribution of space between the items. There is no concept of a track into which a flex item is placed. So there is no area created in which to move the item around in. This is why there is no justify-self property on the main axes in Flexbox. Sometimes, however, you do want to be able to align one item or part of the group of items in a different way. A common pattern would be a split navigation bar with one item being separated out from the group. In that situation, the specification advises the use of auto margins. An auto margin will take up all of the space in the direction it is applied, which is why we can center a block (such as our main page layout) using a left and right margin of auto. With an auto margin on both sides, each margin tries to take up all the space and so pushes the block into the middle. With our row of flex items, we can add margin-left: auto to the item we want the split to happen on, and as long as there is available space in the flex container, you get a split. This plays nicely with Flexbox because as soon as there is no available space, the items behave as regular flex items do. See the Pen Alignment with auto margins by Rachel Andrew. Flexbox And Micro-Components One of the things I think is often overlooked is how useful Flexbox is for doing tiny layout jobs, where you might think that using vertical-align is the way to go. I often use Flexbox to get neat alignment of small patterns; for example, aligning an icon next to text, baseline aligning two things with different font sizes, or making form fields and buttons line up properly. If you are struggling to get something to line up nicely with vertical-align, then perhaps try doing the job with Flexbox. Remember that you can also create an inline flex container if you want with display: inline-flex. See the Pen inline-flex example by Rachel Andrew. There is no reason not to use Flexbox, or even Grid for tiny layout jobs. They aren’t just for big chunks of layout. Try the different things available to you, and see what works best. People are often very keen to know what the right or wrong way to do things is. In reality, there often is no right or wrong; a small difference in your pattern might mean the difference between Flexbox working best, where otherwise you would use vertical-align. Wrapping Up To wrap up, I have a quick summary of the basics of alignment. If you remember these few rules, you should be able to align most things with CSS: Are you aligning text or an inline element? If so, you need to use text-align, vertical-align, and line-height. Do you have an item or items you want to align in the center of the page or container? If so, make the container a flex container then set align-items: center and justify-content: center. For Grid Layouts, the properties that start with align- work in the Block direction; those which start with justify- work in the inline direction. For Flex Layouts, the properties that start with align- work on the Cross Axis; those which start with justify- work on the main axis. The justify-content and align-content properties distribute extra space. If you have no extra space in your flex or grid container, they will do nothing. If you think you need justify-self in Flexbox, then using an auto margin will probably give you the pattern you are after. You can use Grid and Flexbox along with the alignment properties for tiny layout jobs as well as main components — experiment! For more information about alignment, see these resources: CSS Box Alignment (MDN web docs) Everything You Need To Know About Alignment In Flexbox Box Alignment Cheatsheet
  3. Version 2.4.1

    1 download

    Best open source admin dashboard & control panel theme. Built on top of Bootstrap 3, AdminLTE provides a range of responsive, reusable, and commonly used components. AdminLTE Features HTML5 & CSS3 Verified HTML5 and CSS3 syntax by W3C services. Responsive Design Mobile first design. Fits many resolutions, from large desktops to small mobile devices. 1000+ Icons Featuring Font Awesome, Ion Icons, and Glyphicons. 6 Skins Choose a skin that matches your branding or edit the LESS variables to create your own. Enhanced For Printing Support for printing any page. The invoice page makes a perfect example. Lightweight Although AdminLTE is full of features, it was designed to be fast and lightweight. Browser Compatibility Support for most major browsers including Safari, IE9+, Chrome, FF, and Opera. Many Plugins Over 18 plugins and an aditional 3 custom made plugins just for AdminLTE.

    Free

×
×
  • Create New...