I'm trying to troubleshoot a css problem (using bootstrap.css btw).
I've created my own custom css file so that I can add to / or in some cases, replace the bootstrap rule.
I've been using the "Inspect" tool in firefox - under the Web Developer options.
I can see that the style I think should be applied to my page has been crossed out. I just read in another post here on stackoverflow that that means the style has been overwritten. But i don't understand why this is being overwritten or how to further troubleshoot this issue.
The css rule itself is a media query - I'm trying to check for the size of the browser, and then depending on how big it is, change an image. How am i changing my browser size? I'm using Firefox's responsive design view tool instead of doing it manually.
Here's the rule that is being overwritten:
#media (max-width: 360px) {
.hero-unit h1 {
margin-bottom: 0;
font-size: 0.2em;
line-height: 1em;
letter-spacing: -5px;
color: inherit;
}
.hero-unit p {
font-size: 0.2em;
font-weight: 50;
line-height: 1em;
color: inherit;
}
.hero-unit {
background: url("../img/1.jpg");
padding: 1em;
margin-bottom: 2em;
background-color: #eeeeee;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
}
This is the one that is being applied:
#media (max-width: 979px){
.hero-unit h1 {
margin-bottom: 0;
font-size: 2.0em;
line-height: 1.5;
letter-spacing: -1px;
color: inherit;
}
.hero-unit p {
font-size: 1.2em;
font-weight: 20;
line-height: 1.5em;
color: inherit;
}
.btn-large {
padding: 6px 10px;
font-size: 11px;
line-height: normal;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.hero-unit {
padding: 1em;
margin-bottom: 2em;
background-color: #eeeeee;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
h2 {
font-size: 1.5em;
line-height: 2em;
}
}
Can you tell me where I've gone wrong? Thanks.
EDIT 1:
Here's the actual html where this css is supposed to be applied to:
<div class="container">
<div class="span8">
<div class="hero-unit">
<h1> </h1>
<h1> </h1>
<h1> </h1>
<h1> </h1>
<h1> </h1>
</div>
<div class="row-fluid">
<div class="span4">
<h2>list 1 </h2>
<p>list</p>
<p><a class="btn" href="<?php echo base_url();?>index.php/list1/"><i class="icon-list-alt"></i> View details »</a></p>
</div><!--/span-->
<div class="span4">
<h2>list2</h2>
<p>some other list</p>
<p><a class="btn" href="<?php echo base_url();?>index.php/list2/"><i class="icon-globe"></i> View details »</a></p>
</div><!--/span-->
<div class="span4">
<h2>routes</h2>
<p>list of all routes</p>
<p><a class="btn" href="<?php echo base_url();?>index.php/routes/"><i class="icon-globe"></i> View details »</a></p>
</div><!--/span-->
</div>
</div>
It's the hero-unit that has a background image defined in the css. I'm not sure if this is the best way to do this or not, but for the most part, it seems to be working.
Thank you.
If the width of the browser is 360px and the max-width: 979px is below the max-width: 360px in your CSS it will take precedence since both apply to a browserwidth of 360px.
Either move the max-width: 360px below or set a #media (max-width: 979px) and (min-width: 361px).
Also, this is a good read on precedence in CSS, http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade/
Related
I have a minimal example here: https://codepen.io/cpcpcpcpcpx/pen/VwZWoyJ
Containing the following:
.wrapper {
width: 200px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
}
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
The horizontal padding only applies to the very beginning and end of the text where it wraps, but I want it to apply on every line. I'm OK with the border-radius not being at the line-break points of every line, but I need the padding to apply.
If I put padding-top into the .header-text class that applies to both lines, so I'm unclear why the points where lines wrap ignore the horizontal padding options.
Is there a way to do this in CSS?
What you want can be achieve using box-decoration-break and it will even work with border-radius:
.wrapper {
width: 200px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
You should change .header-text display to either block or inline-block
you could try in another way
.header-text {
padding: 0;
word-spacing: 5px;
}
May it will help u out. Increase the width of the .wrapper so the padding will apply.
HTML PAGE
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
CSS Page
.wrapper {
width: 500px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
padding-top:12px;
padding-bottom:12px
}
I have a minimal example here: https://codepen.io/cpcpcpcpcpx/pen/VwZWoyJ
Containing the following:
.wrapper {
width: 200px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
}
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
The horizontal padding only applies to the very beginning and end of the text where it wraps, but I want it to apply on every line. I'm OK with the border-radius not being at the line-break points of every line, but I need the padding to apply.
If I put padding-top into the .header-text class that applies to both lines, so I'm unclear why the points where lines wrap ignore the horizontal padding options.
Is there a way to do this in CSS?
What you want can be achieve using box-decoration-break and it will even work with border-radius:
.wrapper {
width: 200px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
You should change .header-text display to either block or inline-block
you could try in another way
.header-text {
padding: 0;
word-spacing: 5px;
}
May it will help u out. Increase the width of the .wrapper so the padding will apply.
HTML PAGE
<div class='wrapper'>
<h1>
<span class='header-text'>
Long text that wraps
</span>
</h1>
</div>
CSS Page
.wrapper {
width: 500px;
}
h1 {
font-size: 32px;
font-family: Tahoma, Helvetica, sans-serif;
line-height: 50px;
}
.header-text {
background: #aabbcc;
padding-left: 20px;
padding-right: 20px;
border-radius: 6px;
padding-top:12px;
padding-bottom:12px
}
I would like to reproduce the following image with CSS:
Especially important is to me that both lines have equal length:
I tried to recreate it with this code (jFiddle):
.box {
font-family: "Open Sans";
line-height: 28px;
font-weight: 700;
background-color: #2c343c;
margin: 20px;
padding: 20px;
width: 150px;
text-align: justify;
}
.box .name {
color: #fff;
font-size: 24px;
}
.box .sub {
color: #f29400;
font-size: 15px;
letter-spacing: 1px;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="box">
<span class="name">Dr. Nielsen</span><br>
<span class="sub">WEBDEVELOPER
</div>
But its not quite perfect:
Is there a good way how to achieve this with CSS so that both lines get the same lengths on any device. Or is it recommended to rather use a picture for this?
You can give a try to text-align-last:justify;
Beside, to avoid setting a width, you may turn the box into a block that shrinks on its content via display:table; . You can also avoid the <br> setting spans into blocks
.box {
font-family: "Open Sans";
line-height: 28px;
font-weight: 700;
background-color: #2c343c;
margin: 20px;
padding: 20px;
display: table;
text-align: justify;
}
span {
display: block;
text-align-last: justify;
}
.box .name {
color: #fff;
font-size: 24px;
}
.box .sub {
color: #f29400;
font-size: 15px;
letter-spacing: 1px;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="box">
<span class="name">Dr. Nielsen</span>
<span class="sub">WEBDEVELOPER</span>
</div>
<div class="box">
<span class="name">Dr. Nielsen</span>
<span class="sub">WEB-DEVELOPPER</span>
</div>
<div class="box">
<span class="name">Watch Out when top too long</span>
<span class="sub">single-short-breaks!</span>
</div>
You should remove the text-align: justify; on the container (.box) and give .name some extra letter-spacing so the 2 lines line up.
Be aware that this would be completely dependent on the font settings. Another font-family, size, etc. would change the size of both lines and make it different again. If people visiting your website changed their browser font size, then they won't see exactly what you see. If you want to avoid this (as much as possible) then look into font-size resets.
.box {
font-family: "Open Sans";
line-height: 28px;
font-weight: 700;
background-color: #2c343c;
margin: 20px;
padding: 20px;
width: 150px;
}
.box .name {
color: #fff;
font-size: 24px;
letter-spacing: .3px;
/* added */
}
.box .sub {
color: #f29400;
font-size: 15px;
letter-spacing: 1px;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="box">
<span class="name">Dr. Nielsen</span>
<span class="sub">WEBDEVELOPER</span>
</div>
I have an animated header that is basically one stagnant word and preceeding it is a carousel of many words (in the same position) that fade in and out (thanks to animate.css). I followed a tutorial on youtube to get the basic webpage so it may look familiar or simple.
However, the preceeding words are stuck in complicated div's and headers to attempt to get multiple animations (enter and exit for each).
The problem is that when a long word comes onto the screen, it overlaps on the second word.
(Picture included)
To explain briefly, the button and text are all in a "display:table;" div and the words were normally just one cohesive sentence and worked fine. However, I've had to split them up and the only way to prevent them from being above/below one another (VERY annoying) was to force them to float left and right. However, when I delete the floats now (after much 'debugging') it doesnt seem to actually change the design, which greatly worries me. I have included my code. Please help! My idea right now is to make the text right aligned and relative to the second word, but everything I try seems to do absolutely nothing. If there are any other solutions I am all ears.
<section class="intro">
<div class="inner">
<div class="content">
<section style="clear: both">
<div style="position:absolute" z-index="1">
<h1 z-index="inherit"display="inline-block" class="os-animation" data-os-animation="fadeInDown" data-os-animation-delay="0s">
<div text-align="right" z-index="inherit" class="os-animation" data-os-animation="fadeOutDown" data-os-animation-delay="1s">Loving</div></h1>
</div>
<div style="position:absolute" margin-left="15%" z-index="2">
<h1 z-index="inherit" display="inline-block" class="os-animation" data-os-animation="fadeInDown" data-os-animation-delay="1s">
<div text-align="right" z-index="inherit" class="os-animation" data-os-animation="fadeOutDown" data-os-animation-delay="2s">Enjoying</div></h1>
</div>
<div style="position:absolute" z-index="3">
<h1 z-index="inherit" display="inline-block" class="os-animation" data-os-animation="fadeInDown" data-os-animation-delay="2s">
<div text-align="right" z-index="inherit" class="os-animation" data-os-animation="fadeOutDown" data-os-animation-delay="3s">Exploring</div></h1>
</div>
<h1 style="float: right">Irelnd</h1>
</section>
<section style="clear:both" class="os-animation" data-os-animation="fadeInUp" data-os-animation-delay="5s">
Get Started
</section>
</div>
</div>
</section>
css:
#import url('https://fonts.googleapis.com/css?family=Yantramanav:100');
#import url('https://fonts.googleapis.com/css?family=Montserrat:400');
html,body{
margin:0;
padding:0;
height:100%;
width:100%;
}
#carousel {
background-color: green;
text-align: center;
vertical-align: middle;
float: left;
}
#Dubai{
background-color: red;
}
.intro{
height:100%;
width:100%;
margin:auto;
background: url(https://static.pexels.com/photos/470641/pexels-photo-470641.jpeg) no-repeat ;
display: table;
top:0;
background-size:cover;
}
.intro .inner{
display: table-cell;
vertical-align:middle;
width: 100%;
}
.content{
max-width:480px;
margin: 0 auto;
text-align: center;
padding-bottom: 28%;
padding-left: 4%;
}
.content h1 {
font-family: 'Yantramanav', sans-serif;
font-size: 600%;
font-weight: 100;
color: #E1efe9;
line-height: 55%;
}
.btn {
font-family: 'Montserrat', sans-serif;
font-size: 135%;
font-weight: 400;
color: #3c4f1f;
text-transform: uppercase;
text-decoration: none;
border: solid #3c4f1f;
padding:10px 20px;
border-radius: 9px;
transition: all 0.3s;
}
.btn:hover{
color: #a0afa8;
border: solid #a0afa8;
}
p{
font-size: 150%;
line-height: 120%;
font-family: sans-serif;
}
/*--- Media Queries --*/
#media screen and (max-width: 900px) {
.content{
padding-bottom: 30%;
max-width: 320px;
}
.content h1{
font-size: 450%;
}
.btn{
font-size: 130%;
padding: 9px 15px;
}
}
#media screen and (max-width: 768px) {
.content{
padding-bottom: 40%;
max-width: 210px;
}
.content h1{
font-size: 300%;
}
.btn{
font-size: 110%;
padding: 9px 15px;
}
p{
font-size: 120%;
line-height: 100%;
}
}
#media screen and (max-width: 480px) {
.content{
padding-bottom: 50%;
max-width: 173px;
}
.content h1{
font-size: 250%;
}
.btn{
font-size: 90%;
padding: 4px 12px;
}
p{
font-size: 100%;
line-height: 100%;
}
}
Hi everyone I'm fairly new to HTML5/CSS, so I'm in need of some help.
The problem is the image won't go inside the box.
It's current placement is at the bottom left of the box.
I'd like to put it in the left side IN the box and the h2 and p on the image's right side
I'm just stuck as to what I'm missing
Also, is it okay if I create an id for each of the html element? it just seems like there are too many elements, and is this frowned upon in web design? If so, what's the proper way of doing it?
Thanks very much in advance
#featPost {
padding:70px 0px 0px 51.2px;
/* background-color: orange;*/
}
#featPost section {
width: 750px;
height: 261px;
border-style: double;
border-width: 4px;
border-color: black;
}
#featPost figure {
position: relative;
padding-right:20px;
float:left;
}
#featPost h1 {
font-family: "Calibri", Helvetica, sans-serif;
}
#featPost h2 {
padding: 50px 0px 10px 41.5px;
font-size: 30px;
text-align: center;
font-family: "Calibri", Helvetica, sans-serif;
}
#featPost section{
border-style: double;
border-width: 4px;
border-color: black;
}
#featPost p {
padding-bottom: 150px;
font-size: 20px;
}
<aside id="featPost"><article>
<h1> Featured Post </h1>
<section>
<h2> Essay as Easy as 1,2,3 </h2>
<figure>
<img src="images/example.png" width="250" height="250" alt="image of an egg">
</figure>
<p> What? There are rules in writing an essay?? Read more</p>
</section>
</article></aside>
I would suggest to float the image to the left. I updated your code a bit:
HTML:
<aside id="featPost">
<article>
<h1> Featured Post </h1>
<section>
<figure>
<img src="http://placehold.it/250x250" width="250" height="250" alt="image of an egg" />
</figure>
<h2> Essay as Easy as 1,2,3 </h2>
<p>What? There are rules in writing an essay?? Read more</p>
</section>
</article>
</aside>
CSS:
#featPost {
padding:70px 0px 0px 51.2px;
/* background-color: orange;*/
}
#featPost section {
width: 750px;
overflow: auto;
border: 4px double black;
}
#featPost figure {
float:left;
}
#featPost h1 {
font-family:"Calibri", Helvetica, sans-serif;
}
#featPost h2 {
margin-top: 50px;
font-size: 30px;
text-align: center;
font-family:"Calibri", Helvetica, sans-serif;
}
#featPost p {
font-size: 20px;
}
DEMO
h2 and p tag takes full width automatically that's why you are not able to float image.