jsfiddle
I'm trying to create a blog header that is best described as a grid format. Each item will have a specified position- top, bottom, left, right- with a border on each of it's sides. I've got the basic layout down, but finessing it into a pixel perfect grid is a bit beyond my reach. I've attached an image of what it should look like in the end. Below is the code.. what am I missing?
html-
<div id="blog-header">
<span class="blog-logo"><img src="http://placehold.it/262x134" alt="logo" /></span><!-- end blog-logo -->
<div class="mid">
<p class="blurb">Hi, this is a brief bio.<br/>Ok that's it!</p><!-- end blurb -->
<div class="blog-social">
<ul>
<li><img src="http://placehold.it/25x25" alt="facebook" /></li>
<li><img src="http://placehold.it/25x25" alt="twitter" /></li>
<li><img src="http://placehold.it/25x25" alt="instagram" /></li>
<li><img src="http://placehold.it/25x25" alt="pinterest" /></li>
</ul>
</div><!-- end blog-social -->
</div><!-- end mid -->
<div class="right">
<p class="blog-nav">PORTFOLIO<span style="padding: 0 5px 0 5px;">|</span>BLOG<span style="padding: 0 5px 0 5px;">|</span>ABOUT<span style="padding: 0 5px 0 5px;">|</span>CONTACT</p>
<div class="email">
<img src="http://placehold.it/350x50">
</div><!-- end email -->
</div><!-- end right -->
</div><!-- end blog-header -->
css-
#blog-header {
height: 124px;
width: inherit;
margin: 0 auto;
}
#blog-header .mid,
#blog-header .blog-logo {
border-right: 2px solid #333333;
float: left;
}
#blog-header .mid {
padding-left: 15px;
width: 230px;
}
#blog-header .right {
padding-left: 15px;
float: right;
}
#blog-header .blog-logo {
padding-right: 15px;
width: 262px;
}
#blog-header .blurb {
border-bottom: 2px solid #333333;
padding-bottom: 15px;
font-family: Alexandria;
font-size: 80%;
text-align: center;
width: 200px;
}
#blog-header .blog-social {
clear: both;
width: 125px;
margin: 0 auto;
padding: 10px 0 10px 0;
}
#blog-header .blog-nav {
padding: 7px 0 15px 0;
width: 350px;
}
#blog-header .email {
border-top: 2px solid #333333;
padding-top: 17px;
width: 350px;
}
First, try not to style tags in your HTML with id tags. In fact, if at all possible, try not to style with classes either, unless you need to. You should Google CSS Selectors and try to use as many of those to style your HTML.
Since the only image you are using is the big none on the left, you don't need to put a span around it. Just float: left the image.
Also, are you using HTML5? If so, then #blog-header should instead be a tag. If you have more than one header in your document, then you could give it a class to differentiate it if you needed to.
You also don't need a div around your unordered list of social icons. Just float the list, and display:inline the icons. And instead of using images as icons, you should Google Icon Fonts.
There's a lot more, but start there and get back to us once you've made those changes. Just remember, when it comes to HTML and CSS, less is more!
Kindly post us the part where you are stuck at, not the whole css, what you exactly want, then we can help. It's pointless when you make %90 of whole project and ask us to re-write the project as a whole so we can fix your bugs.
By the way, the codes seem to be too long for such a banner. I removed half of your css and they worked exactly same. Either you took these from somewhere or you don't have any methodolody in learning curve.
I recommend you to take professional developing courses which might help you building clear codes.
Related
I'm taking the Free Code Camp course thing and the first project is to create a tribute page to whoever. Mine is on J Dilla, my favorite hip hop producer. God rest his soul. Anyways I'm trying to use a bootstrap thumbnail around a picture of him, with the text/caption also inside the thumbnail. My problem is that it messes up the centering and aligns the thumbnail to the left and I have no idea how to fix it. Here's the relevant code:
<style>
.cool-text {
font-family: Lobster;
font-size: 20px;
}
.image-centering {
display: block;
margin-left: auto;
margin-right: auto;
}
.vertical-centering {
margin-top: auto;
margin-bottom: auto;
}
.gray-background {
background-color: lightgray;
margin: 20px 100px 20px 100px;
border-radius: 5px;
}
.white-background {
background-color: white;
margin: 10px 560px 10px 10px;
}
</style>
<div class="gray-background">
<br>
<h1 class="cool-text text-center">J Dilla</h1>
<h2 class="text-center"><i>The one and only</i></h2>
<br>
<div class="span8 offset2">
<div class="img-thumbnail thumbnails">
<img class="image-centering" src="http://media.lessthan3.com/wp-content/uploads/2014/02/j-dilla-lessthan3.jpg" alt="The man himself."</img>
<p class="text-center">Dilla working on something ill, I presume</p>
</div>
</div>
<br>
</div>
</div>
Also if there's anything glaringly terrible about my code, I'd love some input on how to reformat it. This is my first time asking a question on stack overflow so forgive me if this is the wrong way to do so.
I'm attempting to place a 'notification' style badge over an images. I am using Twitters Bootstrap as a base framework and creating a custom CSS class called notify-badge. But I cannot get anything to line up properly.
Through the magic of Photoshop, here is what I am trying to accomplish.
Here is my CSS code.
.notify-badge{
position: absolute;
background: rgba(0,0,255,1);
height:2rem;
top:1rem;
right:1.5rem;
width:2rem;
text-align: center;
line-height: 2rem;;
font-size: 1rem;
border-radius: 50%;
color:white;
border:1px solid blue;
}
I would like to be able to place any small about of text in the badge and it expand the red circle to fit.
Here is my HTML code.
<div class="col-sm-4">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="myimage.png" alt="" width="64" height="64">
</a>
<p>Some text</p>
</div>
Bunch of different ways you can accomplish this. This should get you started:
.item {
position:relative;
padding-top:20px;
display:inline-block;
}
.notify-badge{
position: absolute;
right:-20px;
top:10px;
background:red;
text-align: center;
border-radius: 30px 30px 30px 30px;
color:white;
padding:5px 10px;
font-size:20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-4">
<div class="item">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="https://picsum.photos/200" alt="" />
</a>
</div>
</div>
Addendum (from the Asker #user-44651)
(moved from the question)
Here is the result of applying this answer.
Adding margin-top:-20px; to .item fixed the alignment issue.
The idea here is to overlay an absolute container on top of a relative one. Here's a similar example:
<div class="image">
<img src="images/3754004820_91a5c238a0.jpg" alt="" />
<h2>A Movie in the Park:<br />Kung Fu Panda</h2>
</div>
The CSS:
.image {
position: relative;
width: 100%; /* for IE 6 */
}
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
This is going to put our text right up on top of the image nicely, but it doesn't accomplish the box we want to achieve behind the text. For that, we can't use the h2, because that is a block level element and we need an inline element without an specific width. So, wrap the h2 inside of a span.
<h2><span>A Movie in the Park:<br />Kung Fu Panda</span></h2>
Then use that span to style and text:
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
For ideas on how to ensure proper spacing or to use jQuery to cleanup the code a bit by allowing you to remove some of the tags from the code and jQuery them back in, check the source.
Here's a fiddle I made with the sample code:
https://jsfiddle.net/un2p8gow/
I changed the notify-badge span into a div. I saw no reason it had to be a span.
I changed the position to relative. Edit - you could actually keep the attribute position: absolute; provided you know what you're doing with it. Guy in the comments was right.
You had the attribute right: 1.5rem; and I simply changed it to left because it was being inset in the opposite direction of your example.
You can tweak it further but in a vacuum this is what you want.
so recently I had opened up my forum and am currently configuring the theme, but have ran into some trouble. On posts, there are stats displayed to the right, but they're too close together and display obscurely. After awhile of research such as positioning, containers, etc., I still haven't been able to find my answer, and still desperately need help. Here's a screenshot of what I'm talking about:
Screenshot 1
This is the CSS for the statistics:
.post .post_author div.author_statistics {
float: right;
font-size: 11px;
padding: 3px 10px 3px 5px;
padding-left: 50px;
color: #666;
line-height: 1.3
}
If you need any extra information, let me know and I can provide it. Thanks in advance for any help!
EDIT: Here's a part of the HTML for the stats.
<span style="font-size:13px;">
<div align="center">
<div class="float_left">Posts:</div> <div class="float_right"> 13</div><br>
<div class="float_left">Threads:</div> <div class="float_right"> 1</div><br>
<div class="float_left">Joined:</div> <div class="float_right"> Oct 2015</div>
<br><div class="float_left">Reputation:</div> <div class="float_right">
<strong class="reputation_positive">2</strong>
<!-- end: postbit_reputation_formatted_link --></div>
<!-- end: postbit_reputation --></div>
<!-- end: postbit_author_user -->
</span>
Try this one
.post .post_author div.author_statistics {
margin-right: 50px;
float: right;
font-size: 11px;
padding: 3px 10px 3px 5px;
padding-left: 50px;
color: #666;
line-height: 1.3;
}
You just need to increase or decrease the margin-right value
Your question is quite confusing as I thought this theme is quite normal in every single forum I had joined.
But you may try this code:
.post .post_author div.author_statistics .float_left {
float: left;
width: 80px;
text-align: left;
}
To achive this:
Hope it helps!
I am building a site using foundation 3 and the native orbit slider.
so far so good... but the slider info does not appear in the correct place in chrome.
ok, easy fix i hear you say...apply chrome specific styles. Good, I like the idea except that messes with safiri, which renders the page fine.
The html:
<div id="featured">
<div>
<img src="images/slider/ironman-txt.jpg" alt="">
<div class="featuredInfo">
<h3>IRON MAN</h3>
<hr />
<p>When Tony Stark’s world is torn apart by a formidable terrorist called the Mandarin, Stark starts an odyssey of rebuilding and retribution.</p>
<ul class="featuredActions">
<li>Watch Trailer</li>
<li>-15 PG Rating</li>
<li>Book Seats</li>
</ul>
</div>
</div>
</div>
The css (scss):
#featured {
background-color: $white;
max-height: 400px;
.featuredInfo {
float: right;
padding: 0 1em;
max-width: 25.5em;
height: 100%;
z-index: 10;
h3 {
padding: 0.5em 0 0.1em 0;
margin: 0;
text-transform: uppercase;
}
hr {
margin: 7px 0;
border-color: $txtColor;
height: 2px;
border-width: 1px;
}
}
a live link:
http://madmantis.co.uk/sites/schwack/
I know that if I add position: relative; and top: -400px; the featured info div will move to the correct position in chrome but obviously knock out the other browsers.
I am a little troubled as using foundation, I can not see what's wrong...
Found a neat little solution...
to differentiate chrome from safari (and other android browsers) the webkit css selector cannot be used.
this tiny script sorted it out:
http://rafael.adm.br/css_browser_selector/
I am going nuts with a whitespace problem inside a div. Two of my divs have unexplained whitespace but a third similar one has none. When I use the compatability mode of IE8 the whitespace disappears so I am guessing it is something to do with the CSS but for the life of me I can't seem to see what.
The page causing the issue is at http://www.infinitedreamers.co.uk/blog/
I have made one of the divs background white to show what I mean.
The snippet of the page is as follows:
<div id="id_front_main">
<div id="id_front_top">
<div id="id_front_top_title">
<h2>Latest Gallery Images</h2>
</div><!--#id_front_top_title-->
<table id="id_gallery_latest"><tr><td width="25%"><img src="http://www.infinitedreamers.co.uk/cpg132/albums/userpics/10001/thumb_Fae4.jpg" height="100" width="86" alt="Contemplation"/><p class="id_title">Contemplation</p></td><td width="25%"><img src="http://www.infinitedreamers.co.uk/cpg132/albums/userpics/10001/thumb_Fae6.jpg" height="100" width="100" alt="Emo Fae"/><p class="id_title">Emo Fae</p></td><td width="25%"><img src="http://www.infinitedreamers.co.uk/cpg132/albums/userpics/10001/thumb_IOTPM.jpg" height="100" width="88" alt="Invasion of the Saucer-Plushies"/><p class="id_title">Invasion of the Saucer-Plushies</p></td><td width="25%"><img src="http://www.infinitedreamers.co.uk/cpg132/albums/userpics/10001/thumb_StarPlushies.jpg" height="100" width="84" alt="Star Plushies"/><p class="id_title">Star Plushies</p></td></tr></table>
<div id="id_front_top_meta">
</div>
</div><!--#id_front_top-->
<div id="id_front_main_holder">
<div id="id_front_left">
<div id="id_front_left_title">
<h2>3d Art Latest</h2>
</div><!--#id_front_left_title-->
<div class="id_latest_posts">
<h3>Getting Started in 3d Art for free</h3>
<span>
<p>You want to create 3d art on the PC or Mac? This is a quick guide on how to achieve this for free.</p>
</span>
</div><!--id_latest_posts-->
<div id="id_front_left_meta">
</div>
</div><!--#id_front_left-->
<div id="id_front_right">
<div id="id_front_right_title">
<h2>Software Latest</h2>
</div><!--#id_front_right_title-->
<div class="id_latest_posts">
<h3>Poser Files Database</h3>
<p>Poser Files Database is designed to aid in the cataloging of content for Poser, DazStudio, Vue, and other similar 3D tools. It can be used simply as a way to find a particular file or to provide detailed information about all products in one location.</p>
<h3>File Renamer</h3>
<p>FileRenamer is a simple batch file renaming utility.</p>
<h3>Database Documenter</h3>
<p>Database Documenter generates easy-to-read and detailed documentation for SQL Server 2000/2005 databases with a few simple clicks.</p>
</div><!--id_latest_posts-->
<div id="id_front_right_meta">
</div>
</div><!--#id_front_right-->
</div><!--#id_front_main_holder-->
</div><!--#id_front_main-->
<div class="clear"></div>
The CSS that applies is as follows:
#id_front_main
{
text-align: center;
width: 100%;
}
#id_front_top
{
width: 100%;
background: url(images/fcover.jpg);
background-repeat: repeat-y;
}
#id_front_top_title
{
width: 100%;
background: url(images/ftop.jpg);
background-repeat: no-repeat;
height: 70px;
}
#id_front_top_meta
{
background: url(images/fmeta.jpg);
height: 31px;
padding-top: 4px;
}
#id_front_main_holder
{
width: 100%;
margin: 0 0 0 0;
padding: 0 0 0 0;
}
#id_front_left
{
width: 45%;
float: left;
/*background: url(images/flcover.jpg);
background-repeat: repeat-y;*/
background: white;
margin-bottom: 5px;
margin-top: 10px;
padding: 0 0 0 0;
}
#id_front_right
{
width: 45%;
float: right;
background: url(images/flcover.jpg);
background-repeat: repeat-y;
margin-bottom: 5px;
margin-top: 10px;
padding: 0 0 0 0;
}
#id_front_left_title, #id_front_right_title
{
width: 100%;
background: url(images/fltop.jpg);
background-repeat: no-repeat;
height: 70px;
}
#id_front_left_meta, #id_front_right_meta
{
background: url(images/flmeta.jpg);
height: 31px;
padding-top: 4px;
}
#id_front_main h2, #id_front_left h2, #id_front_right h2
{
background: transparent;
font: 24px Georgia,century gothic, Arial, sans-serif;
font-weight:normal;
padding-top: 10px;
padding-bottom: 5px;
}
#id_front_left p, #id_front_right p
{
padding: 0 10px 0 10px;
text-align: left;
}
James :-)
The whitespace is caused by the top-margin of the h2 in the boxes. To solve it:
#id_front_main h2, #id_front_left h2, #id_front_right h2 {
...
margin-top: 0;
}
It is always a good idea to reset the styles you are using to avoid these kind of problems when looking at your site in different browsers. There are standard reset style-sheets that can help you with that like:
http://meyerweb.com/eric/tools/css/reset/
Even we faced the similar type of issue.
If you are showing one div at a time, then you can use the below solution:
document.getElementById('myDiv').style.display = 'none';
to the div which is larger in size than the current div shown.
This really works well with IE10 webkit, Chrome Webkit and Safari Webkit.
Cheers,
Ankit