Theres a problem I have throughout my site and I'm unsure how to solve it. When I try to add padding or margins to certain elements they just don't work.
Here is a jsfiddle of part of the site that isn't responding to the css.
https://jsfiddle.net/a90sns1c/
I am trying to add padding to the top of .banner-sub but the padding just overlaps the above elements not pushing it down.
css:
#banner-wrap{
text-align: center;
}
.banner-title{
padding-top: 75px;
padding-bottom: 40px;
color:#fff;
font-size: 42px!important;
}
.banner-icons{
width: 780px;
margin: 0 auto!important;
padding-bottom: 50px!important;
}
#banner-button{padding-bottom: 50px;
}
#banner-content{
background-image:url('../images/banner.png');
background-repeat:no-repeat;
background-size:cover;
background-position:center;
}
.banner-sub{
font-size: 24px!important;
font-family: 'Hind', sans-serif!important;
font-weight: 400;
}
#anchor-icon{padding-bottom: 30px;}
html:
<div id="banner-wrap">
<div id="banner" class="container">
<!-- <div class="banner-bg-img">
<img src="images/banner.png" />
</div>-->
<div id="banner-content">
<h1 class="banner-title">Quality assurance through planning<br /><span class="banner-sub">Nationwide leaflet distribution and sample delivery</span></h1>
<div class="section group banner-icons">
<div class="col span_1_of_4">
<img src="images/icon1.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon2.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon3.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon4.png" />
</div>
</div>
<div id="banner-button"> WHY CHOOSE US</div>
<div id="anchor-icon"><img src="images/down-icon.png" /></div>
</div>
</div>
</div>
Add display:inline-block to .banner-sub class.
.banner-sub {
display: inline-block;
font-family: "Hind",sans-serif !important;
font-size: 24px !important;
font-weight: 400;
padding-top: 200px;
}
jsfiddle
Set display:block; or dispaly:inline-block. <span>is a inline element.
CSS
.banner-sub{
display:block;
font-size: 24px!important;
font-family: 'Hind', sans-serif!important;
font-weight: 400;
padding-top:200px;
}
DEMO HERE
You are applying class .banner-sub on span which is an inline element , as your class .banner-sub does not have any display property set in it , by default display:inline will be set on span as its an inline element.width padding margin wont apply on inline elements (if you are wondering why please see this What is inline , block and Inline-block in css.)
Now for your problem what you can do. i would suggest couple of changes instead of quick-fix (using inline-block) on span.
As i see in you above code you have used h1 tag (default font-size:24px;) but you override it with font-size 42px in your css. so you dont really need h1 here ,instead of using h1 tag use a div and put another div inside instead of span that should be the proper way considering your scenario. posting your code with all the suggested changes.
#banner-wrap {
text-align: center;
}
.banner-title {
padding-top: 75px;
padding-bottom: 40px;
color: #ccc;
font-size: 42px!important;
}
.banner-icons {
width: 780px;
margin: 0 auto!important;
padding-bottom: 50px!important;
}
#banner-button {
padding-bottom: 50px;
}
#banner-content {
background-image: url('../images/banner.png');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.banner-sub {
font-size: 24px!important;
font-family: 'Hind', sans-serif!important;
font-weight: 400;
padding-top: 200px;
}
#anchor-icon {
padding-bottom: 30px;
}
<div id="banner-wrap">
<div id="banner" class="container">
<!-- <div class="banner-bg-img">
<img src="images/banner.png" />
</div>-->
<div id="banner-content">
<div class="banner-title">Quality assurance through planning
<div class="banner-sub">Nationwide leaflet distribution and sample delivery</div>
</div>
<div class="section group banner-icons">
<div class="col span_1_of_4">
<img src="images/icon1.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon2.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon3.png" />
</div>
<div class="col span_1_of_4">
<img src="images/icon4.png" />
</div>
</div>
<div id="banner-button"> WHY CHOOSE US
</div>
<div id="anchor-icon">
<a href="#">
<img src="images/down-icon.png" />
</a>
</div>
</div>
</div>
</div>
Span element has display:inline by default so padding does not effect it. You have to give display:inline-block or display: block the element(.banner-sub).
#banner-wrap{
text-align: center;
}
.banner-title{
position:absolute;
padding-top: 75px;
padding-bottom: 40px;
color:#ccc;
font-size: 42px!important;
}
.banner-icons{
position:absolute;
width: 780px;
margin: 0 auto!important;
padding-bottom: 50px!important;
}
#banner-button{padding-bottom: 50px;
}
#banner-content{
background-image:url('../images/banner.png');
background-repeat:no-repeat;
background-size:cover;
background-position:center;
}
.banner-sub{
font-size: 24px!important;
font-family: 'Hind', sans-serif!important;
font-weight: 400;
padding-top:200px;
}
#anchor-icon{padding-bottom: 30px;}
Related
I'm trying to create buttons and I have a parent div holding all of the other divs together. The thing with the parent div though, it's creating its own width and it just won't create an auto width around the other divs.
I just want to center all the buttons/divs perfectly and the width from the parent div is preventing me.
Any help would be amazing, thank you!!
<style>
h1.helph1 {
text-align: center;
font-family: Montserrat, sans-serif;
font-weight: 100;
padding-bottom: 40px;
padding-top: 20px;
border-bottom: #e3e3e3 solid 1px;
}
.toplinks div, .middlelinks div, .bottomlinks div {
float: left;
width: 250px !important;
}
.helpparent .toplinks div, .middlelinks div, .bottomlinks div{
background: #2fb796;
padding: 10px;
margin: 10px;
color: white;
font-family: Montserrat;
text-align: center;
}
.helpparent {
width: 66.1%;
margin: 0 auto;
}
</style>
<html>
<h1 class="helph1">Forum Help Center</h1>
<div class="helpparent">
<div class="toplinks">
<div class="announcementhelp">Announcements</div>
<div class="gettingstartedhelp">Getting Started</div>
<div class="gasrhelp">GASR 101</div>
</div>
<div class="seperator" style="clear:both;"></div>
<div class="middlelinks">
<div class="forumshophelp">Forums and Shops</div>
<div class="rulesdmcahelp">Community & DMCA Guidelines</div>
<div class="sandrhelp">Support & Report System</div>
</div>
<div class="seperator" style="clear:both;"></div>
<div class="bottomlinks">
<div class="eventhelp">Forum Events</div>
<div class="storehelp">GASR Store</div>
<div class="profilehelp">Your Profile & Settings</div>
</div>
<div class="seperator" style="clear:both;"></div>
</div>
</html>
You can get rid of the width on the .help-parent class and add display: flex; flex-direction: column; align-items: center; to center the divs. However, you must remove the float on the .toplinks div, .middlelinks div, .bottomlinks div for this to work. Also as a result of removing the float, the text-decoration on the links seems to come back, so I added text-decoration: none; to your <a> tags.
<style>h1.helph1 {
text-align: center;
font-family: Montserrat, sans-serif;
font-weight: 100;
padding-bottom: 40px;
padding-top: 20px;
border-bottom: #e3e3e3 solid 1px;
}
.toplinks div,
.middlelinks div,
.bottomlinks div {
width: 250px !important;
}
a {
text-decoration: none;
}
.helpparent .toplinks div,
.middlelinks div,
.bottomlinks div {
background: #2fb796;
padding: 10px;
margin: 10px;
color: white;
font-family: Montserrat;
text-align: center;
}
.helpparent {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
<html>
<h1 class="helph1">GASR Help Center</h1>
<div class="helpparent">
<div class="toplinks">
<a href="https://www.youtube.com/">
<div class="announcementhelp">Announcements</div>
</a>
<a href="https://www.youtube.com/">
<div class="gettingstartedhelp">Getting Started</div>
</a>
<a href="https://www.youtube.com/">
<div class="gasrhelp">GASR 101</div>
</a>
</div>
<div class="seperator" style="clear:both;"></div>
<div class="middlelinks">
<a href="https://www.youtube.com/">
<div class="forumshophelp">Forums and Shops</div>
</a>
<a href="https://www.youtube.com/">
<div class="rulesdmcahelp">Community & DMCA Guidelines</div>
</a>
<a href="https://www.youtube.com/">
<div class="sandrhelp">Support & Report System</div>
</a>
</div>
<div class="seperator" style="clear:both;"></div>
<div class="bottomlinks">
<a href="https://www.youtube.com/">
<div class="eventhelp">Forum Events</div>
</a>
<a href="https://www.youtube.com/">
<div class="storehelp">GASR Store</div>
</a>
<a href="https://www.youtube.com/">
<div class="profilehelp">Your Profile & Settings</div>
</a>
</div>
<div class="seperator" style="clear:both;"></div>
</div>
</html>
Try getting rid of your div element inside your a. This div is unnecessary and is leaving your a without a clickable area.
After that you can choose to use flex to align your content
h1.helph1 {
text-align: center;
font-family: Montserrat, sans-serif;
font-weight: 100;
padding-bottom: 40px;
padding-top: 20px;
border-bottom: #e3e3e3 solid 1px;
}
.toplinks a, .middlelinks a, .bottomlinks a {
width: 250px !important;
}
.helpparent .toplinks a, .middlelinks a, .bottomlinks a{
background: #2fb796;
padding: 10px;
margin: 10px;
color: white;
font-family: Montserrat;
text-align: center;
}
.toplinks, .middlelinks, .bottomlinks {
display: flex;
flex-direction: column;
align-items: center;
}
<h1 class="helph1">Forum Help Center</h1>
<div class="helpparent">
<div class="toplinks">
Announcements
Getting Started
101
</div>
<div class="seperator" style="clear:both;"></div>
<div class="middlelinks">
Forums and Shops
Community & DMCA Guidelines
Support & Report System
</div>
<div class="seperator" style="clear:both;"></div>
<div class="bottomlinks">
Forum Events
GASR Store
Your Profile & Settings
</div>
<div class="seperator" style="clear:both;"></div>
</div>
Basically, I want half the screen to be my image and the other half to have my text. But if the screen is very small, I want the text to go over the image and the image and text shrink. So far I have the big screen working, but when I go into small screen the text is still huge (making it go off the screen) and is still to the right of the image.
.html:
<div class="container-fluid">
<div class="row">
<div class="col-xs-9 col-md-6">
<img class="img-responsive" src="styles/pics/brainimg.png" alt="Brain Image" width="960" height="819">
</div>
<div class="col-xs-3 col-md-6">
<div class="first">
NAME HERE
</div>
<div class="second">
DEVELOPER
</div>
</div>
</div>
</div>
.css
.first{
font-family: Cinzel;
color: black;
font-size: 45px;
font-weight: normal;
}
.second{
font-family: Cinzel;
color: black;
font-size: 20px;
font-weight: normal;
}
It's tricky to answer as you haven't specified what you mean by "too small" or how big your current image is. The smallest device is probably an old iPhone (320px). The following works for 320px but not below as the margin-left here is in pixels (percentage would be ideal). There is a jsbin here
.first {
font-family: Cinzel;
color: black;
font-size: 45px;
font-weight: normal;
}
.second {
font-family: Cinzel;
color: black;
font-size: 20px;
font-weight: normal;
}
#media screen and (max-width:320px) {
.first {
font-size: 16px;
text-align: center;
vertical-align: middle;
left: 0!important;
margin-left: -300px;
color: white;
}
.second {
font-size: 10px;
text-align: center;
vertical-align: middle;
margin-left: -300px;
color: white;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class="row">
<div class="col-xs-9 col-md-6">
<img class="img-responsive" src="http://s3.amazonaws.com/digitaltrends-uploads-prod/2014/06/Brain.jpg" alt="Brain Image" width="960" height="819">
</div>
<div class="col-xs-3 col-md-6">
<div class="first">
NAME HERE
</div>
<div class="second">
DEVELOPER
</div>
</div>
</div>
</div>
You could use media queries to get text over the image. Override position attribute as it is shown here How to position text over an image in css
Also, there is no need to use col-xs-9 and col-xs-3. You can use col-xs-12. Atleast col-xs-3 is not needed (col-xs-9 is a choice).
Something similar to this (not tested):
<div class="container-fluid cntr">
<div class="row">
<div class="col-xs-12 col-md-6 image1">
<img class="img-responsive" src="styles/pics/brainimg.png" alt="Brain Image" width="960" height="819">
</div>
<div class="col-xs-12 col-md-6 text1">
<div class="first">
NAME HERE
</div>
<div class="second">
DEVELOPER
</div>
</div>
</div>
</div>
#media screen and (max-width: 767px) {
.cntr {
position: relative;
}
.image1 {
position: absolute;
left: 0;
top: 0;
}
.text1 {
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
}
}
I have question. I am using materialize CSS. And I tried parallax with the html
<img class="parallax"> tag but is there a way to give you're background image in CSS but also making it parallax.
My Example code:
Content html:
<div class="row parallax-container">
<div class="parallax">
<div class="intro headerBackground">
<h1 class="grey-text text-lighten-5">Data</h1>
<h5 class="grey lighten-4 grey-text text-darken-1">Data</h5>
</div>
</div>
</div>
Content CSS:
.intro
{
text-align: center;
padding-top: 13%;
padding-bottom: 13%;
margin-bottom: 50px;
}
.intro h1
{
font-weight: 900;
text-transform: uppercase;
}
.intro h5
{
text-transform: uppercase;
background-color: #fafafa;
padding: 10px;
display: inline-block;
font-size: 1.2rem;
}
.headerBackground{
height:800px;
background-image:url('images');
background-repeat:no-repeat;
background-position:center;
background-size: cover;
}
Please Try:-
<div class="row parallax-container">
<div class="parallax headerBackground">
<div class="intro">
<h1 class="grey-text text-lighten-5">Data</h1>
<h5 class="grey lighten-4 grey-text text-darken-1">Data</h5>
</div>
</div>
I cannot figure out how to left float a div (filled with text and other divs) inline with an image with a fixed width. I have tried a host of options but I cannot get the second div to float inline.
How do I get the 'sidebbar-post-col2' to float inline with the 'featured-media' image div?
Thanks in advance
http://codepen.io/coreysimons/pen/waQEBE
CODE
.post-container {
width:40%;
display:inline-block;
height:auto;
overflow:hidden;
}
.post {
height:auto;
}
.sidebar-posts .featured-media {
width:auto;
display:block;
}
.sidebar-posts .featured-media img {
max-width: 90px;
max-height: 90px;
margin-right:20px;
overflow: hidden;
}
.sidebbar-post-col2 {
float:left;
width:auto;
display:inline-block;
}
.entry_author_image {
display: inline-block;
}
.author-meta {
font-size: 12px;
letter-spacing: .5px;
font-weight: normal;
margin: 0px;
display: inline-block;
padding: 0px;
float: none;
color: #333;
vertical-align: top;
text-decoration: underline;
}
.author_location {
padding: 0px;
text-transform: none;
font-size: 12px;
color: #999;
font-weight: normal;
letter-spacing: .5px;
display: inline-block;
float: none;
vertical-align: top;
text-decoration: none;
}
.sidebar-posts .post-header h2.post-title {
text-align: left;
font-family: 'Roboto';
font-weight: 900;
font-size: 1.1em;
line-height: 25px;
letter-spacing: 0;
padding-bottom: 10px;
}
.sidebar-posts .category-meta {
text-align:left;
color:#000;
margin-bottom: 5px;
margin-top:0px;
}
.sidebar-posts .post-submeta {
text-align: left;
float: none;
margin-bottom: 24px;
margin-left: 0;
border-bottom: 1px solid #aaa;
padding-bottom: 24px;
}
.sidebar-posts .post-header {
vertical-align: top;
padding:0;
}
<div class="post-container sidebar-posts">
<div class="post">
<div class="featured-media">
<a href="#" rel="bookmark" title="Crazy new GIF lookbook from Kenzo lookbook from Kenzo">
<img width="433" height="558" src="http://coreysimons.com/placeholder/placeholder-img-1.png" class="attachment-post-thumbnail wp-post-image" alt="Screen Shot 2015-07-28 at 22.45.13" /></a>
</div> <!-- /featured-media -->
<div class="sidebbar-post-col2">
<div class="post-header">
<div class="category-meta">Feature, sidebar</div>
<h2 class="post-title">Crazy new GIF lookbook from Kenzo lookbook from Kenzo</h2>
</div><!-- /post-header -->
<div class="post-submeta">
<div class="entry_author_image"><img src="http://coreysimons.com/placeholder/profile-image.png" alt="Corey Simons" width="16" height="16" /></div>
<div class="author-meta">Corey Simons</div>
<div class="author_location">Los Angeles</div>
</div><!-- /post-submeta -->
</div><!-- /sidebar-post-col2 -->
<div class="clear"></div>
<div class="spacer" style="clear: both;"></div>
</div><!-- /post -->
<div class="post">
<div class="featured-media">
<a href="#" rel="bookmark" title="Crazy new GIF lookbook from Kenzo lookbook from Kenzo">
<img width="433" height="558" src="http://coreysimons.com/placeholder/placeholder-img-1.png" class="attachment-post-thumbnail wp-post-image" alt="Screen Shot 2015-07-28 at 22.45.13" /></a>
</div> <!-- /featured-media -->
<div class="sidebbar-post-col2">
<div class="post-header">
<div class="category-meta">Feature, sidebar</div>
<h2 class="post-title">Crazy new GIF lookbook from Kenzo lookbook from Kenzo</h2>
</div><!-- /post-header -->
<div class="post-submeta">
<div class="entry_author_image"><img src="http://coreysimons.com/placeholder/profile-image.png" alt="Corey Simons" width="16" height="16" /></div>
<div class="author-meta">Corey Simons</div>
<div class="author_location">Los Angeles</div>
</div><!-- /post-submeta -->
</div><!-- /sidebar-post-col2 -->
<div class="clear"></div>
<div class="spacer" style="clear: both;"></div>
</div><!-- /post -->
</div><!-- /post-container -->
Ok so you have to do a few things:
1) On .sidebbar-post-col2 take off the float. You also need to add a pixel or percentage width to this div. That must be specified in order for inline-block to work I did 50%for my example.
2) Then on .sidebar-posts .featured-media I added a vertical-align: top; as well as changed display:block to display:inline-block
EDIT:
See my latest JSfiddle here:
https://jsfiddle.net/d239roug/2/
Essentially what I did was:
1) .post class I added display:table
2) On .sidebar-posts .featured-media and .sidebbar-post-col2 I added display:table-cell
The explanation for this is that display:table-cell distributes the space evenly depending on how much the inner content's width takes up within the display:table parent DIV.
I'm recreating a small widget from a psd and trying to put a thin border-right between the 3 container divs I'm using to separate the page into thirds. The divs have height, and I've tried adding in forced height to ensure that isn't the problem, but for some reason it just won't show up. The CSS has CSS Reset at the start, which you can grab from here.
Thanks for any help!
HTML
<div class="container">
<div class="img"><img src="1.png" alt=""></div>
<div class="txt">
<div><p class="title taa">10</p><p class="title2 tab">,000 hrs</p></div>
<div class="sub a"><p id="ac">Behavioural testing</p></div>
</div>
</div>
<div class="container">
<div class="img"><img src="2.png" alt=""></div>
<div class="txt">
<div><p class="title tba">8</p><p class="title2 tbb">years</p></div>
<div class="sub b"><p id="bc">Creafting successful user <br> experience since 2005</p></div>
</div>
</div>
<div class="container">
<div class="txt">
<div><p class="title tca">87</p><p class="title2 tcb">years</p></div>
<div class="sub c"><p id="cc">Collective experience</p></div>
</div>
<div class="img"><img src="3.png" alt=""></div>
</div>
CSS
.container {
display: inline-block;
width: 600px;
height: 300px;
border-right: 10px red;
}
.img {
display: inline-block;
}
.txt {
display: inline-block;
}
.title {
font-family: Helvetica;
font-weight: bold;
font-size: 91px;
display: inline-block;
}
.title2 {
font-family: Helvetica;
font-weight: bold;
font-size: 57px;
display: inline-block;
}
.sub {
font-family: Helvetica;
font-size: 22px;
}
.a {
position: relative;
left: 8px;
}
Change it to border-right: 10px solid red;
Border requires size and type of border; color is optional.