The amount of time you choose to invest is entirely a personal thing. You should spend as much time as you are comfortably able without causing issues in other aspects of your life.
As for what to study, if you are a beginner and unsure, then a guided curriculum is the best way to learn the basics.
FreeCodeCamp is one of the most popular and solutions. It teaches good web development practices and costs nothing.
> The spec really should include something to clear out all previous CSS styles on a given element and its children.
all: unset;
is supported in all relevant browsers except IE11.
Here's a half-assed attempt to make something sort of similar: CodePen
I used skewY transforms, so it's a bit different. Also, adding Slick for the carousel functionality makes the text all blurry in Chrome. Something to do with WebKit font smoothing in 3d transforms? Looks ok in Firefox Developer Edition. Anyway, maybe it's useful to someone.
For the exact same effect, probably yeah, like people are saying, use rotation and perspective, or use colored triangles.
border: 8px solid rgb(74, 75, 74);
border-right: 0;
Or (I think):
border: 8px 0 8px 8px solid rgb(74, 75, 74);
Edit: nope, last method doesn't work.
This is neat! Works well on mobile too. I made a fork changing two things:
I changed the border-style from dashed to solid to eliminate the glitchy-looking 'tail' each item had. I don't think they could ever look completely seamless using a dashed border and CSS alone. Maybe with SVG backgrounds.
I changed the tags from div/p to ol/li since this would literally be a numbered list of items.
I know this is already solved but I wanted to provided an alternate way of doing things (the more you know).
the image should have a width of 100%
Why you may ask does this work?
By setting the overflow to auto on the parent/wrapper div you give the default rule saying "make sure that whatever is in this div, stays in this div". and when you force the image to be 100% width of the div it stretches across all the way, this also makes the element responsive as well, because if the parent shrinks less than whatever you set the width to be, the image will resize accordingly.
I've added a codepen and commented the css rules.
Hope this helps!
Yup. You can play around with the clip
property to achieve what you want - https://codepen.io/BTM/pen/pOybbg
Just keep in mind it's not supported at all in IE / Edge. If yuo need that, you can probably go crazy with semi-transparent backgrounds covering parts of the values instead.
#4 isn't correct. An absolutely positioned element will position itself relative to it's most immediate, non-static parent. And it gets even weirder in that <code>transform</code> also triggers a new 'relative' context for the child element's placement.
Hello Brachamul,
Merely setting display: none
or turning off the visibility won't prevent the browser from requesting the file. In fact, the request for these files is likely to happen much earlier than styles are even applied.
What you could do is assign the ultimate image source to a data-* attribute, and use event-delegation to set data-src attribute values to the src property of any image clicked:
<img data-src="http://placehold.it/200x200" />
Some default styling could ensure that this is visible:
[data-src] { min-width: 10px; min-height: 10px; background: #F00; }
And then a quick delegated-click handler on the document to perform the assignment from the data-src attribute:
document.addEventListener( "click", function setSource ( event ) { if ( "src" in event.target.dataset ) { event.target.src = event.target.dataset.src; delete event.target.dataset.src; } });
This particular approach assumes support for addEventListener and HTMLElement.dataset. Both of these are easily polyfilled.
By taking this approach we prevent the browser from loading the image until we are ready for it to do so.
Caveat, I work on the Internet Explorer team. I'm happy to follow up with further discussion if you like.
@jonathansampson
Probably the easiest options would be looking into SVG or CSS :before to create a shape above a square rectangle DIV
Edit: I have never really used :before and :after but I put this together. It's more like the new chrome tabs but you could probably tweak it to look more like what you want https://codepen.io/anon/pen/rqqZdV
Let's start with a few things:
1) Add this style: * { box-sizing: border-box; }
2) Remove postion: absolute; from body
3) Remove width: 100%; from body
That takes care of the horizontal scroll bar.
To make this a bit better:
1) Add margin: 0; to the body
2) Remove padding: 5px from #main
3) Study up on html5 elements.
4) Use a CSS reset and/or maybe a grid
Right now you're trying
vertical-align: center;
this is not a css property.
Set your HTML/body to height:100%
add a wrapper div around your table, set that to 100% aswell.
remove the top: and margin: auto; property from your table.
set the wrapper to
display:flex; align-items: center; justify-content: center;
this will center it vertically and horizontally.
Little tip: you don't need to use
position: relative;
that much, usually only when you also use a
position: absolute;
somewhere
another ps:
padding-left: 200px; padding-right: 200px;
is the same as:
padding: 0 200px;
Here's a codepen i made, so you can take a look at what i did, i imported the background image, but the other images don't work so don't get thrown off by that. Also if you copy my html, it all goes in your <body> tag. And replace the image links with the ones you were using, also in your CSS
One interesting caveat to note, if FLIF ever catches on and gets wide browser support, then CSS resizing will actually be the best option available. The way FLIF works is that it only downloads as much of the image is required to display at the current resolution. So pointing at giant image won't have any downside, and using the same image for all screen resolutions will work without any downsides.
But FLIF just came out of Beta. So it will probably be a 1-3 years before we see browsers willing to adopt it.
Why don't you try it yourself? There are so many reasons and they'll become apparent when you try!
First off, if you specify a fixed width, the text will overflow if it's too long, look here.
Also, you can only align it in the center horizontally with a defined width & height using text-align. There's no way to align it vertically unless you're gonna use flex.
Also, it looks ugly when the text is right at the edge of the element, you want some space in between.
All the above are fixed using padding, the text will be the origin, therefore centered both horizontally and vertically, and when you use padding you can always have a standard, like a padding of 1 or 2em in all directions and it will work regardless of the length of the string.
There is a difference between using percentage and pixel values. Example: http://jsfiddle.net/95anjwdb/
If the height and the width are equal, you don't see any difference.
But if one side is larger, the border-radius: 50%;
will act differently. In that case, 50%
means "50% of that side". So the corner will actually be an ellipse.
If you use 10000px
, it will remain a circle. The very high value doesn't change anything because the maximum radius will always be half of the height (or of the smaller side) for some reason. In my example, a radius of 15px would be enough (because the div is 30px high). But if I applied the same border-radius to higher divs, I wouldn't want to update the value constantly. So I guess people use border-radius: 10000px
as default. As long as it works...
Kept thinking about this one for some reason and it's been a pretty slow day at work, so... here's version two: CodePen
Most obvious bad thing about this one is the photos look obviously skewed, so you'd have to pre-skew them the other way first to make them look all right.
Since you already have the <h2> in a <div> use this: http://jsfiddle.net/qNPsP/
You need to have some of the css in both elements and add 2 properties in particular:
.banner { max-width: 440px; color: white; font-size: 28px; font-weight: normal; position: absolute; bottom: -10px; padding: 0 8px; left: 8px; }
.banner h2 { display: inline; /* VERY IMPORTANT -- this allows the gaps between lines / line-height: 1.8em; / IMPORTANT -- adjust to taste */ background: rgba(0,0,0,.5); } *edit: added the css in post
That code would make the attributes apply to class2 elements inside of class1 elements. Delete the space between the two classes in the CSS:
.class1.class2 { attributes... }
Play around with CSSDesk; I find it helps a lot.
Also 256 tags override a class
But you still can't have 256 IDs to override an inline style sadly. Not that any of this would be practical in production… more info here on the discussion of the discovery.
>.container {
position: relative;
}
.clear {
~~position: absolute;~~
>
> position: relative;
}
.blurry {
position: absolute;
filter: blur(15px);
}
​
You're going to want to use `position: relative` on your clear element. The double absolute will make the content collapse:
https://codepen.io/anon/pen/YOebNm?editors=000
​
Otherwise, this is the best way to do it! :)
Yes that's right, so 100vh = 100% of the current viewport hight, and 100vw = 100% of the current viewport width.
These are fairly well supported now but be sure to check if the browsers you aim to cater for do indeed support it. More info here: http://caniuse.com/#feat=viewport-units
Demo: http://jsfiddle.net/5LKA8/
OP, just so you're aware - While all 3d methods are considered 'stereoscopic', most people these days think of the modern 'side-by-side' (SBS) style of 3D as 'stereoscopic'. This is what 3D TVs use. Basically it takes two slightly different images, places them next to eachother, then interweaves them together on the screen. If you're not wearing the glasses, it looks very messy, but you don't get any of the 'extra color' given by Red/Cyan style 3D.
Red/Cyan 3D like this is more accurately called 'anaglyph 3D'. Again, it is stereoscopic, but there's a lot of people who might argue that.
Tailwind is very much in the same vein as these CSS frameworks. The biggest differences are:
Tailwind was designed from the ground up to be highly customizable. Unlike other frameworks where your locked into the utilities they provide, Tailwind has a ton of customization options allowing you to tailor the framework specifically for your project.
Tailwind takes a pragmatic approach to class naming. We've prioritized understandable and descriptive classes over having really short classes, or even names that align perfectly with their respective CSS properties.
Tailwind is component friendly. We sit somewhere between BEM and going full-on utility classes. Where it makes sense we encourage creating components, and have even created tooling to make this easy to do.
Finally, we've given our documentation as much care and attention as the framework itself. We believe that having beautiful, easy to understand, easy to navigate documentation will make developer's lives better as they work with our project.
Then I would use grid instead of flex, you don't need to nest since it's made for layouts like this and it's nicely responsive thanks to the fr unit.
Here's an example of how I would solve it with grid.
Negative margins are not hacks in a technical way, they are allowed by the spec after all, but there might be a better way of solving you layout problems, especially with support for flex-box becoming more uniform.
That being said, if you feel like this is a (mental) hack, put it into shame.css and dedicate some time finding alternatives.
https://codepen.io/Vizor/pen/erGyrr
Here is a solution using flex-box. Flex-box is probably the most advanced, yet production ready CSS IMO.
EDIT: cleaned up my code because it was a bit messy.
Don't use "hacks" with top/bottom/margin/absolute when doing layout when you see it is not properly aligned.
Check out flexbox (Chris Coyier: https://css-tricks.com/snippets/css/a-guide-to-flexbox/), it has an amazing way to do layout. Be aware of the browser support though (http://caniuse.com/#feat=flexbox).
Otherwise in general, use chrome dev tools to see if you can solve the puzzle yourself. It has a lot of features in Elements tab -> Styles :)
Hey, here's a quick tip to really help you out. Most modern browsers have Inspection Tools built in, they make figuring this stuff out a lot easier so you'll want to become familiar with them if you're going to be making other changes in future!
Using Chrome, you can right click on a page area and then select 'Inspect Element' to bring up a few panes containing information about the item you chose.
In this case, what I did was navigate to the working demo these guys provided, inspected the main background area and checked the 'styles' pane on the right hand side of the inspection tools to see which rules are being applied.
See where it says 'background: #f8f8f8'? That's what we want to replace, instead with something like
background: url('path/to/your/image.png');
You can do it right there in the inspection tools to preview the change, but of course these changes won't be saved until you actually make the change in your stylesheet. So back to your question, where do we do that?
In your style breakdown pane you can click the link next to any rule to view the stylesheet, doing that we find the responsible code is:
/* BEGIN @include oxygen.css */ html,body { background: #f8f8f8; }
So, I'd check your oxygen.css file for that selector ("html,body") and make the change I suggested previously, save it and away you go!
Also, if you're having trouble with sizing and positioning your image, check out the Mozilla Developer Network. Here's their info on the background-image property, and you'll find links to other useful properties (background-size, background-position) in the navigation menu.
Or LESS...
After seeing what a preprocessor can do for stuff like this I will never, ever go back.
In your mixins file declare:
.border-radius(@radius: 2px){
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
Then, in your css all you ever have to do for border radius from that point on is:
.some-div{ .border-radius(8px); }
.some-other-div{ .border-radius(12px); }
It's feckin' brilliant, man.
Regarding efficiency:
The first option is the least efficient. It's four times larger (number of characters) than .1, .2, .3, .4 {border:1px solid black}
. This will eat into your bandwidth over time (obviously, your little example is so small that it isn't going to matter, but for larger stylesheets it does).
-
Now, about your last question, about giving them all the same class: only give these four div
s the same class if they are conceptually related. Are they all the same kind of thing? Have the same kind of purpose?
If they just happen to be styled the same (eg: you want them all to have the same black border), that in-itself is not a good reason to apply the same class to them^1. All in all, you should usually go with the .1, .2, .3, .4 { ... }
version typically. Then later on, if you want to style .2
differently, you can either remove it from the list or add a second .2 { ... }
elsewhere to add more styling.
-
^1 you may want to use a meta-language, like sass, which allows you to define mixins, so that your stylesheets remain DRY.
IE10 and up. The spec was only finalized last year. You can use it freely with every modern browser.
Only Safari still requires vendor prefixes.
You can see browser support here: http://caniuse.com/#search=flexbox
For development, it might make sense to namespace your CSS files for large chunks of code. And then you run a process to consolidate all of those files into one file to be served as an asset. Gulp.js exists for automated tasks like these. I highly recommend checking it out and using it alongside something like SASS.
I really like the css courses on Treehouse . It has a monthly subscription cost but you can try it out for free.
You could also try something like Free Code Camp
CSS is not terrible - can you imagine how the internet would look without it?
That being said, I believe floats will be very helpful to your layout here. However, no one will really be able to help you unless we can see your progress thus far. Would it be possible for you to set up a test case on jsfiddle.net or codepen.io?
Too many potential reasons to guess without seeing the code, but it’s probably because you’re using an element that doesn’t expand vertically like you’re expecting it to. Probably floating a div...
If you want code help, it helps to share your markup in something like https://codepen.io so we can answer with more certainty.
The Good
The Bad
Works only on browsers that support flex-wrap
.
The Ugly
I use a bunch of dummy divs that I push off the screen with a negative margin.
Right now it seems to be used more for mobile app grids because mobile browsers support Flexbox more uniformly. Eventually I believe this (display: grid;) will replace the current systems. But as you can see the browser support isn't good right now so Flexbox is currently used.
Color theory is more about exposure to palettes and context than simple, strict rules.
As has been mentioned before, check out Adobe Kuler, and specifically their most popular section. Take a look and you will start to see commonalities and trends. Think of ways you would use these, or even just what they remind you of.
If sets your brain to think of the context of colors, and will make you think more about them moving forwards.
Ah I see, z-index issue.
If you match the container z-index to that of the shadows, it works fine:
http://cssdeck.com/labs/mc54ejog
Notice .container now has:
position: relative; z-index: -1;
This should do the trick:
<style> .slide-up { position:relative; padding-bottom:100px; display: block; width:100px; -webkit-transition: all .5s ease; -moz-transition: all .5s ease; -o-transition: all .5s ease; transition: all .5s ease; }
.slide-up:hover { -webkit-transform: translate(0,-50px); -moz-transform: translate(0,-50px); -o-transform: translate(0,-50px); -ms-transform: translate(0,-50px); transform: translate(0,-50px); } </style>
<span class="slide-up">My text here</span>
Here is a demo of this.
pure CSS, no. use SASS http://sass-lang.com/documentation/file.SASS_REFERENCE.html#extend
but why not just add both the red and blue classes to the element you want? that way it will have all properties from both classes
The great thing about SASS is that it has a huge community of open-source plugins and frameworks to get involved in.
http://sass-lang.com/community
There are other options like Rework that are more hardcore, but I'd play with .LESS or SASS a bit before jumping into the deep end with those.
Check out escaping (or collapsing) margins. Here's a link on escaping margins. That's where that extra margin is coming from... it's the heading.
I didn't actually know about @supports, but after looking at caniuse i'm not sure i'll use it yet.
p.s. Although fuck IE support, maybe I will use it.
p.p.s Although supports would only really be useful for IE because the other major browsers aren't retarded.
2 major disadvantages:
Flexboxes are the long-term solution here, which will also have the most graceful failure mode (it'll just be an unaligned block if the flexboxes aren't supported, rather than broken visible content).
Try https://teamtreehouse.com/library/css-basics
You need to understand HTML first, what elements are, what selectors are.
> being able to change how youtube presents/shows info on the page as said in the link?
Basically once you understand HTML elements and CSS selectors, you can use CSS properties. If you use web inspector, you can override CSS properties and see how it's going to look like, modified. That's how we decide how many pixels etc.
For completeness:
@media (max-width: 600px) { .sometimes-hidden-img { display: none; } }
This will hide the image with class sometimes-hidden-img
if the screen width is less than 600px.
You could also do it conversely, and only show the image on larger screens. This doesn't ultimately make a difference to the result but might make more sense as a "default" value depending on what else you're doing.
.sometimes-shown-img { display: none; } @media (max-width: 600px) { .sometimes-shown-img { display: block; } }
EDIT: It depends on the specifics of your situation, but there's other stuff you could do. If you want to hide all but the first image on small screens, you could use:
@media (max-width: 600px) { .span-that-overflows-neatly img + img { display: none; } }
(Note that the class is on the span now, not the image.)
You might also consider using white-space: nowrap
and overflow: hidden
. I've made an example of this using text instead of images.
I've had this issue before, the issue is that FireFox doesn't like this sort of animation on the body (probably worth filing a bug), so I moved it into a div and positioned it absolutely to the four corners. You could probably also use position:fixed depending where this is going.
https://codepen.io/anon/pen/qXZLpo
On a side note, you can ditch those vendor prefixes (except -web-kit because of iOS) and also, and, FireFox can be a little funny if you don't set the default value of something that you're animating. So I've consistently set background-color across all the declarations just to be safe.
box-sizing: border-box
will do the trick. Actually you should use it on all your projects so you don't have to set negative margins or calculate borders and paddings.
Check out Sublime Text 2. Absolutely phenomenal text editor.
Using Sublime Text 2, make a selection, then go Edit > Tag > Wrap selection with tag...
Hope that helps. I'm not sure if Notepad++ has a similar feature.
I like jsfiddle myself, as I deal a lot with Javascript as well, but it's useful too for testing out CSS.
codepen.io is also used for this exact purpose, and it does update on-the-fly, whereas jsfiddle requires you to 'Run' the code each time.
I misread the post at first but here you go!
-webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,1), rgba(0,0,0,0));
I would wrap the price section in another div and give the padding to it instead of the entire price wrapper. like this. https://codepen.io/designwithbrown/pen/VEyVVJ
It's not a browser bug, you've overcomplicated this so much and all your styles are interfering with each other.
It's because you're trying to animate something that already has an animation applied to it.
You should use CSS transitions not animations for this.
Also not really sure why you need to set the menu to display none and then back to display block, that's probably got something to do with it as well.
​
Check this codeine as a reference of the direction you should go in.
In CSS keyframe animations you can use keyframe selectors in percents (0% - 100%) instead of from and to. So, you could say, rise up from 0% to 10%, stay where you are from 10% to 90%, and fall down from 90% to 100%. Here is an example.
because you're setting min height instead of max height. that rule will be applied if you change that to a max height. that way it will target viewports lower than 400px wide, and lower than 900px tall. your screen is at 569 high so its under the minimum height
Hi alex. I know what you mean and I knew someone would point that out. :-)
It's true that backgrounds are more flexible in terms of styling. Like you mentioned, background-size: cover
is a typical case. It can be done with an <img>
tag but I found it not worth the hassle.
Also, the background image can be just decorative, like on Medium articles: https://medium.com/bull-market/whats-a-tax-9e75f6b0e957
I took background-image
as an example of dynamic styling, but it can be other properties as well. For example, if an admin interface lets you pick a color (to be used as background or as text color), then inline styling is the best option (the other would be to write <style>
tags in the page).
Standard syntax is now > background: linear-gradient( to left, rgba(255, 0, 0, 1) 0%, rgba(255, 255, 0, 1) 15%, rgba(0, 255, 0, 1) 30%, rgba(0, 255, 255, 1) 50%, rgba(0, 0, 255, 1) 65%, rgba(255, 0, 255, 1) 80%, rgba(255, 0, 0, 1) 100%);
and is supported on all modern browsers. You need to left instead of just left. You also may have to add the other prefixes for older browser support. Your codepen would only work for moz browsers at the minute.
You can also achieve the same effect with Border-Image.
For the form, would something like this work?
http://jsfiddle.net/rEs6t/embedded/result/
Some of the labels/inputs might need to be rearranged, but this solution is pretty simple and uses percent values for scale.
Ideally you could simply wrap all of your fieldset
elements, float it to the left, then keep the legend in its own element floated to the right.
Here's a final result; multiple forms and a legend:
http://jsfiddle.net/Edcmf/1/embedded/result/
(Click "edit" in the upper right to see the code)
Because the links in the nav box have 1px of padding on the left + right:
#home, #work, #me, #contact, #homeload, #workload, #meload, #contactload { padding: 0px 1px; position: relative; right: 2px; display:inline; font-family: 'Lucida Sans Unicode'; font-size: 11px; }
... And using top/right/bottom/left on relatively-positioned elements is usually not a good idea since the element is still a ghost in it's original position.
Moving on, you should not be using divs to create a navigational element. Ideally, a simple nav should look like this:
<nav> <ul> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> <li><a href="#">Page 4</a></li> </ul> </nav>
With this approach, you are using the sweet new HTML5 nav element, and you're semantically correct in using a list to make a list of links. It just makes sense.
<strong>Please watch this fantastic video on simple HTML5/CSS navigation by Jeffery Way.</strong>
Also, you do not need to use images to create those colored lines. That can be done with a very simple CSS3 box-shadow, if not a border-top, like so:
.navitem{ box-shadow: red 0 -3px 0; }
...Which should work in all major browsers (even IE9!).
I apologize in advance for the block of text. If you run into any issues, please don't hesitate to ask questions.
Is there a reason you can't compile the SCSS into CSS? SCSS is not meant to be the end product.
If you have Ruby installed, you can install SASS with gem install sass
Then compile the CSS with
sass input.scss output.css
There are a bunch of extra options like minification & whatnot, but the basics should suffice. Read up here: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass
Edit A little Googling came up with a couple plugins for Visual Studio to handle SASS (looks like even compiling it for you). This one looks promising & powerful (though I have zero experience with Visual Studio)
If you're talking about map tag, it's not quite useful to use it. You can't change CSS properties of map/area. You might consider using SVG + jQuery option: http://www.sitepoint.com/dynamic-geo-maps-svg-jquery/
If you're okay using FlexBox you can do it with just two lines of code. FlexBox usage is still questionable from my understanding but it's supported by all current browsers. Safari requires the -webkit- prefix but other than that support is pretty common now, although supporting previous browsers not so much. It really depends on what this is for. Also don't quote me on any of my support claims :p http://caniuse.com/#feat=flexbox
Just add these two lines to the parent:
.work { display: flex; justify-content: space-around; }
Your codepen adjusted so: http://codepen.io/anon/pen/JovbmP
P.S. You can remove margin: auto;
and display: inline-block;
from the child
elements assuming those are there to space out the children.
P.P.S. I see each of your children has a class named .work1 .work2 .work3
etc. That's really unnecessary as you can reference these with the nth-of-type
selector. So to reference the second child of work you could just make your selector work div:nth-of-type(2) {}
. Little extra tid-bit for you :p
When you say "scale appropriately" are you taking about responsive design?
If so, there are a lot of unknowns here, and I would go back and ask the designer how he expects this design to look at a narrow view.
EDIT: also, viewport units are a nice choice, but browser support could be a problem. No support in IE8 or any Android except 4.4 stand out as potentially major concerns unless you're into providing fallbacks.
To specify a breakpoint, you need a media query, something like:
.element { /* styles that apply universally here */ }
@media screen and (min-width: 400px) {
.element {
/* styles that apply at 400px and up go here (400 just an example) /
}
}
@media screen and (min-width: 900px) {
.element {
/ styles that apply at 900px and up go here (900 just an example) /
}
}
@media screen and (max-width: 900px) {
.element {
/ This media query is MAX-width, only applies up to 900px here. */
}
}
More on media queries here: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries
Sometimes you don't need media queries, depending on your layout and the exact effect you want. In a layout such as yours, using floats that drop down to the next line(s) on smaller screens might work just fine. Even Flexbox might work, depending on which browsers you're supporting and if you need/are willing to write some fallbacks for older browsers. http://jsbin.com/goleqeriri/1/edit?html,css,output is a version of what you're trying to do, but then using Flexbox.
Is this the effect you were after? Div elements are block elements, which means they have a line break after them. Adding:
display:inline-block;
to the divs will display them like inline elements (i.e. no line break) whilst keeping the correct size etc...
Then you can add:
text-align:center;
to the css for the 'holder' div to have them centered.
(anybody please correct me if I've said anything wrong - I'm still quite new to this)
Hey AshenLordofCinder,
Here's a little codepen demo! https://codepen.io/anon/pen/xrLNoy
For a custom stacking order, each div will need position: relative
. Otherwise applying z-index does nothing and assumes the natural stacking of elements.
What we see in your example is that the nested div with z-index: 3 will actually rest underneath of the last div. The parent div of z-index: 3 has a z-index of 1. This means the child is actually stack 1 layer 3. The last div is stack 2 which stacks on top of stack 1.
To have z-index: 3 stack on top of the last div, you would need to remove z-index: 1 from the parent.
Ahh, that has to do with the margin, h tags have a default margin on the top and bottom.
Try changing "margin: 18;" to "margin-top: 0; margin-bottom: 18px;"
Also, if im not wrong, margin needs a value in px, %, em.. etc to actualy work (except if you want 0).
Edit: Check out this pen if that is what you are after.
Edit 2: If you want further read-up on how margins work, check this out.
This is happening because of two things:
<p> elements automatically take up the entire width of the parent element, so since you have <a> elements before it, it naturally breaks down on to the next line.
Since you're setting a height of 42px on the parent element, the <p> tag visually breaks out of the blue box. You can easily fix this by adding this CSS:
#media a { float: left; }
This causes all of the <a> tags to float to the left of the container without causing the next non-floated element to break on to the next line.
Part of your problem is that, while you intend to capture a hierarchical structure, you're using the same pieces to represent both levels. Since they're both pills, there's no visual reinforcement to the hierarchy.
Your top level items could conceptually be thought of as tabs, since they pivot the user between "spaces." Perhaps styling them to look more like tabs would help. The second level are really "actions" that occur within the currently selected space. I'd try to make them look like buttons, to reinforce that clicking on them is more of a "do something" than a "take me somewhere."
If I can use Bootstrap as an example, I'd shoot for something like their tab navigation for the top level and a button group for the second.
http://codepen.io/joeyhoer/pen/ipwDk
I believe newer versions of Safari are doing this by default, but the link above might offer more control.
This article was a thing for awhile: https://medium.com/designing-medium/crafting-link-underlines-on-medium-7c03a9274f9
You can do this by setting the content box's left and right margins to auto, which centres it horizontally within its parent. Note that this only works if the box has an explicit width!
Take a look here: http://jsfiddle.net/k8z7pep3/1/
http://jsfiddle.net/rLxLt2vz/22/
Here you go. I'm not an expert, but I think the default padding and margins of some elements is what was causing the problem. What I added to the css removes default padding and margin values from all elements, and it seems to have fixed it.
Do you want people to be able to interact with the video - play, pause, etc?
Or do you just want a video element playing something in the background, not meant to be touched?
~~The latter is easy. The former is not.~~
Actually I'm sorry, that's just really easy. I just found a new favorite CSS rule. Unfortunately it is pretty bleeding-edge as far as IE is concerned, but I think going forward you'd be safe to use it.
{ pointer-events: none; }
">" is the child selector.
It targets a child element that is a direct descendant of the element. It will only go to the next level of elements in the tree and no further. Without the > symbol, the selector will target all descendants.
<style> .class_name span { color: blue; text-decoration: underline; } .class_name > span { color: red; } </style>
<div class="class_name"> <span>This text is red and underlined</span> <h1> <span>This text is blue and also underlined</span> </h1> </div>
Also, you need to make the fixes as mentioned in /u/skeletorcares post.
ok, yes, much easier. this also allows us to pop updates into the fiddle: http://jsfiddle.net/j9gvn83s/4/ . this should get you a bit further. fix your html issues as well (correct src's, add self close to img tags).
i'd suggest adding a reset, as that will take care of a lot of the layout issues.
secondly, you can't reuse id's within a document. so id="arrow" is not allowed. class="arrow right" and class="arrow left" would work. that would allow you to hook generic properties to the arrow, and specific properties to the left and right arrow. this will also become more important later, when you start hooking more js into it.
you might want to set the background color to the body, html so that if your wrapper isn't 100% of the height/width, it doesn't show white (as with your bad screenshot).
setting 100% of the height is probably not going to work as you intend. Especially once you start floating items around. Once things are floated, the divs will collapse. there is a common fix, known as a clearfix. this will be important for your nav as well, once you fill in more of it. this is also probably what that js snippet is trying to fix.
you probably don't want to set all imgs to float left. this may give you problems further down the road. especially with that #body, as that is a tough specificity to override.
this is a terrible forum to post code. try getting it up on http://jsfiddle.net/ . the easier you make it for us to help you, the more help you'll get.
now, that's a nice image of what you get, but what are you trying to get? other than "not that"? do you have a mock up of what you are trying to accomplish?
Here's one I created through a bit of cheating: http://jsfiddle.net/1495g4ws/1/
Basically, what I did was put the faded image (the "background") on the top, and put it in a div with overflow: hidden;
. That means when the container (#loading_indicator_container) gets smaller, the progress appears larger. Just set #loading_indicator_container's height
property to 100 minus whatever percent you're loaded.
I added :focus
so it works for keyboard users too, and got rid of the fixed button positioning. I think support should be IE9+, but pseudo-element can work in IE8 with the old single colon syntax.
You can achieve a similar effect with one line of CSS. http://jsfiddle.net/nqjcf00s/6/
Box Shadows can take an extra parameter to shrink them:
box-shadow: 0 100px 50px -110px rgba(0,0,0,0.7);
Required reading: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
You'll need to use Javascript as far as I know for this, here is an example, where you click and JS changes the classes
Absolute positioning works as intended if the positioned element has a parent container that has either position:relative or position:absolute applied to it. I may not fully grasp your exact use case (and some example code depicting the problem would help a ton), but here is an example of using bottom and top to position images. Try changing the browser width to see how bottom and top properties work.
Then my interpretation was correct, and you are approaching it completely backwards. You should designate a spot for each of the items and toggle their opacities with a class on the item: https://codepen.io/anon/pen/PdvBKG
If you really need to do it with classes on the parent container — which again I highly doubt — you can do it like this: https://codepen.io/anon/pen/BOePxR
I agree with the other comment about breaking it down into smaller tasks. If you had first searched for how to make items transparent, you would have found that you do not need to remove them to do so.
No problem. If you look at your screenshot, I can help you see why the color is remaining blue. On the right of the inspector, it tells you which files each rule can be found in, and it lists the files in reverse order of how they were loaded. So the top most file was loaded last.
The blue is being applied in the index (main page) of your site. It is loaded after all of your other CSS, including the file where black is being applied. Since it obeys the cascade, the blue trumps the black.
I don't know if you have control over which is loaded first, but a quick and dirty way of fixing it is to change your custom code to color: #000000 !important
. This should be a last resort for when you don't have control over the order of your CSS or the rules defined in your index.
Finally, I added the necessary rule to your pen to get an underline on hover: https://codepen.io/anon/pen/vzZZMN
Make the gif a child of the text. Give the text a position: relative;
property and the gif a position: absolute;
. This will give you control over the position of the child relative to its parent. I made an example here: https://codepen.io/anon/pen/GXrLvX
So I did some testing and yes, it looks like margin does accomplish things that those two can't. Auto margin appears to do a similar thing to align-self
. justify-self
however does not do what you would expect. In my example justify-self
has no effect.
Reading more, I found that justify-self
is ignored in flexbox layouts. It works in layouts like grid.
Check my fork again. https://codepen.io/andyxanthos/pen/PBVpJR
I also made some other changes to the footer, so it will display at 100% of the viewport width.
As for the second part of your question, could you clarify?
Edit: Nevermind, I see what you mean. Check it now. If it works, I'll explain what I did. Be sure to change to the full view, not just the preview.
They are called tooltips.
Like every other thing with HTML / CSS, there are tons of ways archieving the same result.
One option for example would be using pseudo elements. Libraries for frameworks like react might use more like a js and DOM manipulation way for such result
Edit: Some starting points
https://www.w3schools.com/css/css_tooltip.asp
https://www.freecodecamp.org/news/a-step-by-step-guide-to-making-pure-css-tooltips-3d5a3e237346/
Yes I am here is a link https://www.producthunt.com/posts/windframe I have made a lot of updates after this initial launch I will be relaunching it there in the coming weeks
IE11 should work fine with media queries. Not sure about other versions, since we don't support them, but you can check 'em out at http://caniuse.com
Try to strip your declaration to just @media (max-width: XXXpx)
. It should work.
The Good
The Ugly
I use a bunch of dummy divs with a negative margin, and I need to squish their height to 0.
You could do something like this: http://jsfiddle.net/bdfnL87e/
This won't be infinite, but it will last a long time.
Honestly, I would probably use JavaScript for this myself. I would still use CSS for the transition, but loop it using JavaScript.
What would probably be an even better approach, would be to use a video. Slow moving transitions don't usually look so smooth when done in code.
Here's a basic demo of what you could do. You don't need to set the width of your paragraph tag unless you really need to, because as a block-level element, it will expand to the width of your wrapper container.
It's complicated.
What floats originally were intended to do is make text go around blocks, not to be used for layouting. That's what they still do, technically, and that is what is causing the effect you're witnessing.
The inline-block element is getting treated as text, so the floats push the text away. That is why the entire 20 pixel high block is getting pushed down by the floats.
The block element, however, is not getting pushed down. Only it's content, the text itself, is getting pushed down. So your 20 pixel high red bar is now behind the two floated bars. This might sound really silly, but that's how floats work. :-)
Also something you might not have known and might have confused you: just because you give a block element a fixed height doesn't mean text can't continue out of it. If you want to avoid this, use overflow: hidden
. http://jsfiddle.net/83Uf2/1/ .
In your case, the red background looked like "disappeared" because the text appeared outside of the red block due to the floats.
So, how can you avoid that? There are several ways:
float: left;
on all 3 blocks. display: inline-block;
on all 3 blocks. This might not work how you want it to, since the blocks are actually treated as if they were inside text ('inline') with this one.clear: left;
on #footer
.In case you don't know clear
yet: clear is basically a "place this element below all floated elements before this"-instruction. What you can give to clear is 'left', 'right' or 'both', telling it which types of floats to clear.
CSS has many non self-explanatory things like this. It's all just a matter of getting to know them. Proper CSS has enough of these, be glad you don't really have to worry about all the quirks of the old Internet Explorers that much anymore. ;-)
Hope I was able to help.
I have updated your fiddle with how I do css drop downs, your problem was that you closed the li tag around menu 2, you needed to close it after the ul.submenu so that you can target it using css.
You could use :nth-of-type(n) selector to target the fourth element of the respective element type. However, this would work only if that element is always the fourth in the list.
> JS Fiddle
The images are not yet added to the site to share code, but you can see how the "grid" moves to the left. https://codepen.io/MoroccoSun/pen/ERBVMV :D
Hi, I played a little bit with your layout. https://codepen.io/anon/pen/QrPmor. The cards are taking the viewport height (vh) as reference. Sure there is still potential to optimize but i need to stop for now, because of an appointment i have in a few minutes.
https://codepen.io/anon/pen/LmjXPj
Adapted from this:
https://css-tricks.com/examples/ShapesOfCSS/#tv
I'm pretty sure the outlines / hollow shape can't be done in CSS. I'm more than happy to be proven wrong, though!