I'm creating a style sheet for use on mobiles and the text needs to be condensed down into one column, rather that the two that are displayed side by side on a desktop.
I'm wondering whether my issue has anything to doing the positioning that I have applied to the divs?
Please see this fiddle http://jsfiddle.net/vtdo8vc0/
#col1 {
position: relative;
display: inline;
float: left;
width: 94%;
padding-right: 3%;
padding-left: 3%;
}
#col2 {
position: relative;
display: inline;
float: left;
width: 94%;
padding-right: 3%;
padding-left: 3%;
}
.col {
font-family: 'Avenir-Book';
font-size: 12px;
line-height: 16px;
font-weight: 500;
}
#main_content {
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
}
#main_content img {
width: 100%;
height: auto;
padding-bottom: 30px;
}
#header {
position: relative;
padding-top: 3%;
padding-left: 3%;
padding-right: 3%;
padding-bottom: 3%;
}
.header {
font-family: 'Avenir-Book';
font-size: 26px;
line-height: 26px;
text-transform: uppercase;
font-weight: 900;
}
<div id="container">
<div id="header">
<div class="header">
food
</div>
</div>
<div id="col1">
<div class="col">
At Danny’s we believe food is very important! Kevin our Head Chef has a wealth of experience and a passion to rival that experience. Wherever possible our food is created using the very best locally sourced ingredients. Whether you are
</div>
</div>
<div id="col2">
<div class="col">
popping in for a lunchtime wrap or a full blown Danny's Burger you can expect the same level of service and attention to detail.
<br>
<br>Check out our menu below.
</div>
</div>
<div id="main_content">
<img src="http://placehold.it/350x150" />
</div>
</div>
If I understand correctly, you want the two columns to behave like they're ons wall of text, at least on narrower screens. Then the solution would be to make #col1, #col2 and .col inline and dispense with the floats.
#col1,
#col2 {
position: relative;
display: inline;
}
.col {
display: inline;
font: 500 12px/16px'Avenir-Book', sans-serif;
}
#main_content {
padding: 0 10px 10px 10px;
}
#main_content img {
width: 100%;
height: auto;
padding-bottom: 30px;
}
#header {
position: relative;
padding: 3%;
}
.header {
font: 900 26px/26px'Avenir-Book', sans-serif;
text-transform: uppercase;
}
#media all and (min-width: 50em) {
/* change into 2 columns on wider screens */
#col1,
#col2 {
display: block;
float: left;
width: 47%;
padding: 0 3%;
box-sizing: border-box;
}
}
<div id="container">
<div id="header">
<div class="header">
food
</div>
</div>
<div id="col1">
<div class="col">
At Danny’s we believe food is very important! Kevin our Head Chef has a wealth of experience and a passion to rival that experience. Wherever possible our food is created using the very best locally sourced ingredients. Whether you are
</div>
</div>
<div id="col2">
<div class="col">
popping in for a lunchtime wrap or a full blown Danny's Burger you can expect the same level of service and attention to detail.
<br>
<br>Check out our menu below.
</div>
</div>
<div id="main_content">
<img src="http://placehold.it/350x150" />
</div>
</div>
Related
Currently putting CSS touches on a landing page. How do I get my p elements to align underneath my h2 elements? Like how I'd like it to look like:
Here’s what mine looks like:
And here’s the link to the CodePen.
Thanks in advance.
* {
font-family: Arial;
}
#media (max-width: 768px) {
* {
font-family: Tahoma;}
}
#header {
position: fixed;
width: 100%;
display: flex;
top: 0;
background-color: white;
opacity: 0.8;
}
#header img {
height: 75px;
width: 75px;
margin-top: -10px;
}
#header h1 {
font-size: 23px;
margin-left: -20px;
}
#header nav {
margin-left: 730px;
margin-top: 15px;
}
#header a {
color: black;
text-decoration: none;
}
.nav-link {
margin-right: 10px;
}
#glove {
margin-top: 100px;
margin-left: 50px;
}
.glove-feature {
display: flex;
flex-direction: row;
}
.glove-feature img {
height: 100px;
width; 100px;
}
.description {
padding: 5px;
margin-top: -10px;
margin-bottom: 15px;
}
#features {
margin-top: 50px;
}
#features h2 {
text-align: center;
}
#features iframe{
display: block;
margin: 0 auto;
}
#pricing {
margin-top: 100px;
text-align: center;
border: 1px dashed black;
width: 50%;
margin-left: auto;
margin-right: auto;
display: block;
}
#pricing h3 {
font-weight: normal;
}
#pricing p {
font-style: italic;
}
#close {
margin-top: 50px;
text-align: center;
font-size: 20px;
}
input[type=submit] {
background-color: #DBBC58;
border-radius: 6px;
}
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<div id=header>
<img src="http://www.free-icons-download.net/images/lightning-bolt-logo-icon-76715.png" alt="Lightning" id="header-img">
<h1>Lightning-Fast Muay Thai Gloves</h1>
<nav id="nav-bar">
Why this glove?
Features
Pricing
</nav>
</div>
<div id="glove">
<div id="leather" class="glove-feature">
<img src="https://png.icons8.com/ios/1600/leather-filled.png" alt="leather" id="leather-img">
<div class="description">
<h2>Authentic Leather</h2>
<p>Leather that won't crack and endure even the harshest blows. Straight from Phuket province.</p>
</div>
</div>
<div id="science" class="glove-feature">
<img src="https://cdn3.iconfinder.com/data/icons/pixomania/128/science-512.png" alt="science" id="science-img">
<div class="description">
<h2>Aerodynamically Tested</h2>
<p>Gloves that have been tested time and time again to ensure the fastest strike. Testers may have been injured in the process.</p>
</div>
</div>
<div id="sewing" class="glove-feature">
<img src="https://cdn2.iconfinder.com/data/icons/eldorado-appliance/40/sewing_machine-512.png" alt="sewing" id="sewing-img">
<div class="description">
<h2>Hand-made</h2>
<p>Each and every glove is made in our Bangkok factory from scratch. That's the only way to make sure we deliver what we promise.</p>
</div>
</div>
</div>
<div id="features">
<h2>In-Depth Look</h2>
<iframe id="video" width="600" height="400" src="https://www.youtube.com/embed/xo2xuNYKO0I" frameborder="0" allowfullscreen></iframe>
</div>
<div id="pricing">
<h2>Pricing</h2>
<h3>$49.99</h3>
<p>And if it doesn't last you 36 months...we'll give you a full refund.</p>
</div>
<div id="close">
<form id="form" action="https://www.freecodecamp.com/email-submit">
Take your bouts to the next level: <br>
<input id="email" type="email" placeholder="Email" name="email"><br>
<input id="submit" type="submit">
</form>
</div>
You needed an extra div around your h2s and ps to format them correctly inside of a flex parent. I simplified your CSS and HTML to the minimal correct example, also choosing to use classes instead of IDs for CSS selectors to remove duplicate styles:
* {
font-family: Arial;
}
.glove-feature {
display: flex;
flex-direction: row;
}
.glove-feature img {
height: 150px;
width: 150px;
}
.description {
padding: 10px;
}
<div id="glove">
<div id="leather" class="glove-feature">
<img src="https://png.icons8.com/ios/1600/leather-filled.png" alt="leather" id="leather-img">
<div class="description">
<h2>Authentic Leather</h2>
<p>Leather that won't crack and endure even the harshest blows. Straight from Phuket province.</p>
</div>
</div>
<div id="science" class="glove-feature">
<img src="https://cdn3.iconfinder.com/data/icons/pixomania/128/science-512.png" alt="science" id="science-img">
<div class="description">
<h2>Aerodynamically Tested</h2>
<p>Gloves that have been tested time and time again to ensure the fastest strike. Testers may have been injured in the process.</p>
</div>
</div>
<div id="sewing" class="glove-feature">
<img src="https://cdn2.iconfinder.com/data/icons/eldorado-appliance/40/sewing_machine-512.png" alt="sewing" id="sewing-img">
<div class="description">
<h2>Hand-made</h2>
<p>Each and every glove is made in our Bangkok factory from scratch. That's the only way to make sure we deliver what we promise.</p>
</div>
</div>
body {
background: #911f3c
}
.content-title {
font-family: teko;
color: white;
text-align: center;
font-size: 40px;
padding-top: 80px;
padding-bottom: 50px;
letter-spacing: 2px;
text-transform: uppercase;
}
.container {
font-family: teko;
color: white;
font-size: 30px;
line-height: 35px;
padding-bottom: 50px;
padding-left: 20px;
padding-right: 20px;
}
.column-left {
float: right;
padding-left: 30px;
width: 30%;
}
.column-right {
float: right;
width: 33%;
}
.column-center {
display: inline-block;
width: 33%;
}
<h3 class="content-title">
Explore - Discover - Enjoy
</h3>
<div class="container">
<div class="column-center">Explore the limitless archive of the worlds highest quality cinematic sports videos </div>
<div class="column-left">Enjoy the vast selection of videos and learn the stories behind the creation of the art</div>
<div class="column-right">Discover your favourite film makers, content creators and athletes within the industry</div>
</div>
I am creating a quick project for uni and i am struggling on this one little aspect. I really want to add 3 separate, relatively small, rounded images below the 3 word title but above each column (see the attached image). But every time I do it all the text moves around and it just being a massive pain.
How can I get this working?
Assuming you're not using any framework like bootstrap, this should do the trick:
body {
background: #911f3c
}
.content-title {
font-family: teko;
color: white;
text-align: center;
font-size: 40px;
padding-top: 80px;
padding-bottom: 50px;
letter-spacing: 2px;
text-transform: uppercase;
}
.col-container {
margin-left: 20px;
margin-right: 20px;
}
.col {
float: left;
width: 33.3333%;
}
.col-content {
margin-bottom: 30px;
padding-left: 15px;
padding-right: 15px;
text-align: center;
}
.col-content img {
display: inline-block;
vertical-align: middle;
}
.col-content p {
font-family: teko;
color: white;
font-size: 30px;
line-height: 35px;
text-align: justify;
}
<h3 class="content-title">
Explore - Discover - Enjoy
</h3>
<div class="col-container">
<div class="col">
<div class="col-content">
<img src="https://dummyimage.com/100/">
<p>
Explore the limitless archive of the worlds highest quality cinematic sports videos
</p>
</div>
</div>
<div class="col">
<div class="col-content">
<img src="https://dummyimage.com/100/">
<p>
Discover your favourite film makers, content creators and athletes within the industry
</p>
</div>
</div>
<div class="col">
<div class="col-content">
<img src="https://dummyimage.com/100/">
<p>
Enjoy the vast selection of videos and learn the stories behind the creation of the art
</p>
</div>
</div>
</div>
I hope this helps :)
So I have 3 boxes that need to have a particular height and width and have set them within bootstrap as child elements. Looks good in full view as:
However, when the window resizes, the boxes shift to the left rather than float in the middle of that background graphic. Additionally, the header text (in yellow) loses its upper padding as:
Figured the "responsiveness" was taking over but cannot pinpoint it and am hoping some of you can help.
My HTML for these are:
<div class="container">
<div class="claimHead col-md-12">
<div class="submitHeader" style="margin-top: 60px; margin-bottom: 60px; margin-left: 30px;">
<h1 style="font-size: 36px;">Claim Submission Tool</h1>
<p style="font-size: 18px;">Filing claims has never been easier, it's a simple as 1, 2, 3</p>
</div>
<div id="stepsContainer">
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepOne">
<p class="claimStepNumber">1</p>
<p class="claimStepTitle">step one</p>
<p class="claimStepText">Get started by entering your claim information in the fields below.</p>
</div>
</div>
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepTwo">
<p class="claimStepNumber">2</p>
<p class="claimStepTitle">step two</p>
<p class="claimStepText">Next drag & drop or upload your documentation.</p>
</div>
</div>
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepThree">
<p class="claimStepNumber">3</p>
<p class="claimStepTitle">step three</p>
<p class="claimStepText">Now you're ready to submit your claim and await reimbursement.</p>
</div>
</div>
</div>
</div>
</div>
And my css is:
#stepsContainer {
text-align: center;
}
.stepsBox {
padding-bottom: 60px;
}
.claimSteps {
padding-top: 40px;
width: 335px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
text-align: center;
}
.claimStepNumber {
font-size: 38px;
background-color: #ffffff;
color: #2dccd3;
width: 65px;
height: 65px;
border-radius: 50%;
margin-left: 135px;
}
.claimStepTitle {
color: #ffffff;
font-size: 18px;
}
.claimStepText {
text-align: center;
margin-left: 33.3%;
width: 33.3%;
}
Any ideas on what I can do here and where to check? Am also using Bootstrap 3 on top of this css, but I do not see where it is causing the boxes to shift left justified.
Thanks much.
Columns are floated to the left by default and because you're using a fixed height/width inside of the columns (.claimSteps), they have no choice but to align left once the medium column collapses since they cannot occupy 100% of the smaller viewport.
The heading alignment has to due primarily to your HTML structure.
Note that one area you should consider changing is the width of the box you're creating. It's too wide and starts to break/overflow because it's fixed. If you can reduce it, you should (my examples reflect this but can easily be changed back to your default width.)
The fixed size of the box also comes into play at around 400px. In the second example I made the box flexible so it works properly across all viewports. See examples 1 and 2 on viewports under 400px.
Here are a few examples that may help.
Example 1: Standard Setup
.submitHeader {
margin: 60px 0;
}
.submitHeader h1 {
font-size: 36px;
}
.submitHeader p {
font-size: 18px;
}
.claimSteps {
width: 285px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
text-align: center;
position: relative;
margin: 0 auto;
display: table;
}
.claimStepNumber {
margin-top: 40px;
font-size: 38px;
background-color: #ffffff;
color: #2dccd3;
width: 55px;
height: 55px;
border-radius: 50%;
position: absolute;
display: table-cell;
left: 50%;
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%);
}
.claimStepTitle {
color: #ffffff;
font-size: 18px;
margin-top: 110px;
}
.claimStepText {
text-align: center;
margin-left: 33.3%;
width: 33.3%;
}
#media (min-width: 1200px) {
.submitHeader {
margin: 60px 40px;
}
}
#media (max-width: 991px) {
.claimSteps {
margin: 30px auto;
}
.submitHeader {
margin-top: 60px;
margin-bottom: 0;
text-align: center;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="submitHeader">
<h1>Claim Submission Tool</h1>
<p>Filing claims has never been easier, it's a simple as 1, 2, 3</p>
</div>
<div class="row">
<div class="col-md-4">
<div class="claimSteps" id="stepOne">
<p class="claimStepNumber">1</p>
<p class="claimStepTitle">step one</p>
<p class="claimStepText">Get started by entering your claim information in the fields below.</p>
</div>
</div>
<div class="col-md-4">
<div class="claimSteps" id="stepTwo">
<p class="claimStepNumber">2</p>
<p class="claimStepTitle">step two</p>
<p class="claimStepText">Next drag and drop or upload your documentation.</p>
</div>
</div>
<div class="col-md-4">
<div class="claimSteps" id="stepThree">
<p class="claimStepNumber">3</p>
<p class="claimStepTitle">step three</p>
<p class="claimStepText">Now you're ready to submit your claim and await reimbursement.</p>
</div>
</div>
</div>
</div>
Example 2: Mobile First Setup
.submitHeader {
margin: 60px 0;
}
.submitHeader h1 {
font-size: 36px;
}
.submitHeader p {
font-size: 18px;
}
.claimSteps {
width: 285px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
text-align: center;
position: relative;
margin: 0 auto;
display: table;
}
.claimStepNumber {
margin-top: 40px;
font-size: 38px;
background-color: #ffffff;
color: #2dccd3;
width: 55px;
height: 55px;
border-radius: 50%;
position: absolute;
display: table-cell;
left: 50%;
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%);
}
.claimStepTitle {
color: #ffffff;
font-size: 18px;
margin-top: 110px;
}
.claimStepText {
text-align: center;
margin-left: 33.3%;
width: 33.3%;
}
#media (min-width: 1200px) {
.submitHeader {
margin: 60px 40px;
}
}
#media (max-width: 991px) {
.claimSteps {
margin: 30px auto;
}
.submitHeader {
margin-top: 60px;
margin-bottom: 0;
text-align: center;
}
}
#media (max-width: 400px) {
/*Color For Demo Only*/
body {
background: red;
}
.claimSteps {
width: 100%;
height: 100%;
padding-bottom: 40px;
}
}
/*Color For Demo Only*/
#media (max-width: 320px) {
body {
background: lightblue;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="submitHeader">
<h1>Claim Submission Tool</h1>
<p>Filing claims has never been easier, it's a simple as 1, 2, 3</p>
</div>
<div class="row">
<div class="col-md-4">
<div class="claimSteps" id="stepOne">
<p class="claimStepNumber">1</p>
<p class="claimStepTitle">step one</p>
<p class="claimStepText">Get started by entering your claim information in the fields below.</p>
</div>
</div>
<div class="col-md-4">
<div class="claimSteps" id="stepTwo">
<p class="claimStepNumber">2</p>
<p class="claimStepTitle">step two</p>
<p class="claimStepText">Next drag and drop or upload your documentation.</p>
</div>
</div>
<div class="col-md-4">
<div class="claimSteps" id="stepThree">
<p class="claimStepNumber">3</p>
<p class="claimStepTitle">step three</p>
<p class="claimStepText">Now you're ready to submit your claim and await reimbursement.</p>
</div>
</div>
</div>
</div>
Example 3: Text Alignment Example
.claimSteps {
width: 285px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
margin-top: 30px;
margin-bottom: 30px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<h1>Claim Submission Tool</h1>
<p>Filing claims has never been easier, it's a simple as 1, 2, 3</p>
<div class="row">
<div id="stepsContainer">
<div class="col-md-4">
<div class="claimSteps"></div>
</div>
<div class="col-md-4">
<div class="claimSteps"></div>
</div>
<div class="col-md-4">
<div class="claimSteps"></div>
</div>
</div>
</div>
</div>
You should add class="row" before using the class="col-**-**" as common after class="container".
Have you tried separating your col-md-12 from those three stepBox's?
I don't see it necessary to wrap those columns inside the first column, so I would just rather end the col-md-12 before the #stepsContainer begins.
Another thing is that clearly your CSS limits the width of the claimSteps to be less than the screen width is when the md break-point occurs. You should in at least this point change the width property in CSS with media query.
#media (max-width: 1199px)
{
.claimSteps { width: 100%; }
}
That should do it.
Default div display as block, so it float to left, if you want set it float to the middle, you must set his display to inline-block and set container text-align to center
in your case you can add inline-block display to the .claimSteps CSS rules
.claimSteps {
padding-top: 40px;
width: 335px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
text-align: center;
display: inline-block;
}
For header, you can use padding instead of margin in div.submitHeader
See snippet for full result
#stepsContainer {
text-align: center;
}
.stepsBox {
padding-bottom: 60px;
}
.claimSteps {
padding-top: 40px;
width: 335px;
height: 285px;
background-color: #2dccd3;
color: #ffffff;
text-align: center;
display: inline-block;
}
.claimStepNumber {
font-size: 38px;
background-color: #ffffff;
color: #2dccd3;
width: 65px;
height: 65px;
border-radius: 50%;
margin-left: 135px;
}
.claimStepTitle {
color: #ffffff;
font-size: 18px;
}
.claimStepText {
text-align: center;
margin-left: 33.3%;
width: 33.3%;
}
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="claimHead col-md-12">
<div class="submitHeader" style="padding-top: 60px; padding-bottom: 60px; padding-left: 30px;">
<h1 style="font-size: 36px;">Claim Submission Tool</h1>
<p style="font-size: 18px;">Filing claims has never been easier, it's a simple as 1, 2, 3</p>
</div>
<div id="stepsContainer">
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepOne">
<p class="claimStepNumber">1</p>
<p class="claimStepTitle">step one</p>
<p class="claimStepText">Get started by entering your claim information in the fields below.</p>
</div>
</div>
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepTwo">
<p class="claimStepNumber">2</p>
<p class="claimStepTitle">step two</p>
<p class="claimStepText">Next drag & drop or upload your documentation.</p>
</div>
</div>
<div class="col-md-4 stepsBox">
<div class="claimSteps" id="stepThree">
<p class="claimStepNumber">3</p>
<p class="claimStepTitle">step three</p>
<p class="claimStepText">Now you're ready to submit your claim and await reimbursement.</p>
</div>
</div>
</div>
</div>
</div>
I realise this question has been asked before but none of the solutions i have read through have given me a fix.
Basically i have 4 responsives boxes within a div and as i move down the screen sizes the css first-child and nth-child selectors wont work EVEN though i have used the exact same code for another set of boxes below this set and this works perfectly??
As you will see the bottom 2 boxes act as normal but the top two boxes are stuck together even though the css for the margins have been set to prevent this. It's possibly an easy fix but after banging my head off this all last night I feel like giving up.
Any help would really be appreciated, thanks!
HERE is a fiddle showing exactly what is going on: http://jsfiddle.net/f284xyjh/
Here is the HTML code:
<section id="content">
<div class="container">
<div id="about">
<h1><a name="about">WE'RE GOOD... JUST ASK OUR CLIENTS!</a></h1>
<div id="about-text">
<p>Above The Fold is a Dublin based creative, digital marketing agency that provides a personal, professional and passionate service tailored specifically to each of our clients no matter the size. We specialise in creative digital solutions centred around the user and aim to provide a rich user experience for people interacting with your brand online. Blending creativity with technical know-how and research we can brand, plan, design and build your websites and online campaigns<p>
</div><!-- end of about-text -->
</div><!-- End of about -->
<div id="services">
<a name="services"></a>
<div class="service">
<div class="service-info">
<img src="images/creative-design.png" alt="Creative Design icon" />
<h3>Creative Design</h3>
<p>Creativity is at the heart of what we do. Combining creative thinking with technology to deliver beautiful websites that stand out and engage your target audience.</p>
</div>
<div class="find-out-more">FIND OUT MORE</div>
</div>
<div class="service">
<div class="service-info">
<img src="images/branding-icon.png" alt="Branding icon" />
<h3>Branding</h3>
<p>Much more then simply the design of a website. Through strategic planning and research we create dynamic brand icons (logos) that define who you are.</p>
</div>
<div class="find-out-more">FIND OUT MORE</div>
</div>
<div class="service">
<div class="service-info">
<img src="images/strategy.png" alt="Social Media Marketing icon" />
<h3>Social Media Strategy</h3>
<p>Social media marketing gives you an opportunity to expose your brand to a wider audience. All our campaigns are strategically planned to maximise your reach. </p>
</div>
<div class="find-out-more">FIND OUT MORE</div>
</div>
<div class="service">
<div class="service-info">
<a href="#"><img src="images/digital-marketing.png" alt="Digital Marketing icon" />
<h3>Digital Marketing</h3></a>
<p>Your business is unique so you need an online strategy that is designed for you. We deliver research driven results that create awarenss of your brand or services</p>
</div>
<div class="find-out-more">FIND OUT MORE</div>
</div>
</div><!-- end of services -->
</div><!-- End of content container -->
</section><!-- end of top-content section -->
And here's the CSS code:
.container {
width: 1160px;
margin: 0 auto;
overflow: hidden;
}
#content {
height: 605px;
background: #F3F3F2;
margin-top: 1px;
padding-top: 25px;
}
#about {
width: 100%;
display: inline-block;
text-align: center;
}
#about p {
font-family: "Proxima Light",Arial,helvetica,garuda,sans-serif;
font-size: 24px;
line-height: 28px;
margin-bottom: 10px;
}
#about-img {
background: url(../img/about-img.png) no-repeat;
width: 370px;
height: 154px;
float: left;
margin-right: 20px
}
#about-text {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #333;
line-height: 23px;
}
#services {
width: 100%;
display: inline-block;
}
#services h3 {
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
color: #FFF;
}
#services p {
font-size: 16px;
line-height: 20px;
color: #FFF;
}
#services a {
text-decoration: none;
}
.service {
background: #3498db; url(../images/service-find-out-triangle.png) no-repeat center 256px;
width: 275px;
height: 295px;
float: left;
margin: 20px 20px 20px 0;
text-align: center;
position: relative;
}
.service:last-child {
margin-right: 0;
}
.service-info {
background: #3498db;
width: 255px;
height: 245px;
padding: 20px 10px 0;
}
.service img {
margin-bottom: 10px;
}
#media only screen and (max-width : 1224px) {
.container {
width: 1000px;
margin: 0 auto;
overflow: hidden;
}
#content { height: auto;}
.service { width: 490px; margin: 20px 20px 20px 0;}
.service:first-child { margin-right: 0!important;}
.service:nth-child(2) { margin-right: 0!important;}
.service-info { width: 465px; }
}
#media only screen and (max-width : 1024px) {
.container { width: 800px;}
.service { width: 390px;}
.service-info { width: 370px; }
}
#media only screen and (max-width : 824px) {
.container { width: 680px;}
.service { width: 330px;}
.service-info { width: 310px;}
}
#media only screen and (max-width : 768px) {
.container { width: 95%;}
.service { width: 100%; margin: 20px 0;}
.service-info { width: 94%; }
}
}
This selector: .service:nth-child(2) { margin-right: 0!important;} isn't working because the element you are trying to select is not the 2nd child.
Also...by the way, neither is this one: .service:first-child { margin-right: 0!important;}.
The first-child is the anchor tag
<a name="services"></a>
Accordingly, you should use
.service:nth-child(3) { margin-right: 0!important;}
instead...in this specific instance.
JSfiddle Demo
I am realtively new to HTML/CSS and working on a responsive site. I'm sure I have some improper techniques at this point but aesthetically things are working okay for me so far. MY problem is functional when my screen size gets below full view. Around 768 only 1 link (the contact link) seems to work and I'm not sure why. Any help would be much appreciated! Thanks!
HTML:
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>my<br/>name</h1>
<div id="nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>SERVICES</li>
<li>CONTACT</li>
</ul>
</div>
</div>
<div id="content">
<div id="feature">
<p>Feature</p>
</div>
<div class="article column1">
<p>Column One</p>
</div>
<div class="article column2">
<p>Column Two</p>
</div>
<div class="article column3">
<p>Column Three</p>
</div>
</div>
<div id="footer">
<p>Footer Text</p>
</div>
</div>
</body>
</html>
CSS:
body {
max-width: 90%;
margin: 0 auto;
font-size: 100%;
}
h1 {
font-family: 'bikoblack';
text-transform: uppercase;
font-size: 3em;
line-height: 85%;
color: #2d9471;
background-color: #1a5642;
float: left;
padding: 1em;
}
#header {
overflow: hidden;
z-index: "";
}
#nav {
position: relative;
top: 11em;
margin-bottom: 1 em;
}
li {
display: inline;
font-family: 'bikoregular';
color: #2d9471;
padding: 4em;
}
#feature{
margin: 1%;
background-color: #1a5642;
padding: 5em;
}
.column1, .column2, .column3 {
width: 31.3%;
float: left;
margin: 1%;
background-color: #1a5642;
}
.column3 {
margin-right: 0%;}
}
#feature, .article {
margin-bottom: 1em;
}
#media (max-width:480px){
#nav {
position: relative;
top:.05em;
width:200px;
}
}
#media (max-width:767px) and (min-width:481px){
#nav {
position: relative;
top: 5em;
}
}
The list items in your navigation have a large padding and they are also positioned inline. When they break on the next line (because there is not enough horizontal space) they overlap. The padding of the ones coming last in the list extend over the links above and cover them up. That's why you can't click them.
Try this as a quick fix:
li {
display: inline;
font-family: 'bikoregular';
color: #2d9471;
padding: 0 4em; /* removed padding at the top and bottom */
}