At the moment I am trying to change the distance between the two headers but I can't seem to remember how.
my css for the header is
.header {
font-family: "Karla" !important;
color: #4e4e4e;
}
and part of the html specific to the header is
<div class="header">
<h1 style="display: inline-block">Text 1</h1>
<h1 style="display: inline-block">Text 2</h1>
</div>
the two headings are very close to each other and I would like to separate them more but I can't remember how. I have tried using margin and padding but it doesn't seem to be spacing them out.
The entire website looks like
Thanks
I would recommend the following CSS:
.header h1 { margin: 0px 10px; }
Change the second value (10px) for more horizontal space. This will also keep the headers in the center by adding space for each header on both sides: left & right.
My recommendation would also be to remove the style attribute from the h1 elements and add it to the CSS above. The final CSS would be:
.header h1 {
margin: 0px 10px;
display: inline-block;
}
You can add these three options and play with it:
.header {
font-family: "Karla" !important;
color: #4e4e4e;
line-height: 30px;
margin:0px;
padding:0px;
}
Well out of many ways to do that I would suggest you to add margin to your h1 tags. You can either add margin right to the first h1 tag or you can add margin left to the second h1 tag.
<div class="header">
<h1 style="display: inline-block; margin-right: 2rem;">Text 1</h1>
<h1 style="display: inline-block">Text 2</h1>
</div>
The above given HTML code snippet would do the required and if you wish to increase the space more, just change the value provided for margin right in the first h1 tag.
Related
what is a reasonable solution to get a gap in-between these elements?
What my goal is to get a gap in between <h2>Subtitle</h2>, <h3>STARS, Tartopp Road</h3> along with the paragraph element.
I have already tried utilizing line break however it becomes too large leading me to use line-height or margin-bottom within <br/>.
...just to mention 'margin-bottom: -10px;' was used decrease the gapes between lines
I AM EXTREMELY SORRY STRUGGLING TO GET MY CODE ONTO BODY THEREFORE IM USING JSFIDDLE. LINK BELOW.
Im trying to get this layoutenter image description here
If I'm understanding the question correctly, margin-bottom will work just fine. The issue you may be running into here is that margins are collapsible. This means that when <h3> is directly below <h2>, only <h2>'s bottom margin is being rendered by the browser. When you remove <h2>'s bottom margin, the browser renders <h3>'s top margin, so the space between the elements doesn't change. What you have to do is remove <h3>'s top margin, then set <h2>'s bottom margin to whatever you want.
h2{
margin-bottom: 10px;
}
h3{
margin-top: 0;
}
<h2>Subtitle</h2>
<h3>STARS, Tartopp Road</h3>
grid-gap: 1em;
grid-gap is your friend here. You're using the display:grid system which allows you to specify the gap between elements consistently. After this gap you can format individual elements such as your p, h1, h2 selectors with more specific margin/padding/line-height to fit your needs.
Update: The image you provided shows your trying to achieve a different spacing which you could easily do without blanking out all the default margins and padding for the h1, h2, h3 and p elements in your CSS.
Here is a j-Fiddle with some adjustments and taking out the grid display system. Obviously it's a quick draft which needs small adjustments but let the semantics of your HTML control your structure:
<div class="grid-item-workshops">
<!--
Use header to group your headers together
so they can be easily formatted in your CSS
-->
<header>
<h1>WORKSHOP TITLE</h1>
<h2>Subtitle</h2>
</header>
<!--
Use a br in the midst of the h3 if you
want to keep these grouped as a sub-header with the date.
Or even better, use the <date> and <address> tags here
so you can format them separately. This has the nice
side effect smaller margins as they're not h3 tags.
-->
<date>25-29th July 2016</date>
<address>TARS, Topp Road</address>
<!-- Use paragraph here 👍 -->
<p>...</p>
<!--
This is not a header so lets make it
a <div> with a class that represents what it is showing
-->
<div class="price">£25 A DAY</div>
</div>
And here's some SASS in case the fiddle doesn't work in future:
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
width: 100%;
background: linear-gradient(90deg, ghostwhite 0%, rgb(255, 255, 255) 10%, rgb(255, 255, 255) 90%, ghostwhite 100%);
}
.grid-item-workshops {
background-color: #19252A;
background-size: cover;
background-repeat: no-repeat;
border-image-width: 100%;
border: none;
padding: 0.2em 1em;
color: white;
font-size: 1em;
font-weight: bold;
text-align: left;
height: auto;
header {
margin: 1em auto;
font-size: 1.2em;
line-height: 2em;
h1,
h2 {
margin: 0 auto;
color: cyan;
}
}
date,
address,
p {
font-family: 'Roboto', sans-serif;
}
.price {
font-weight: bolder;
font-size: 2em;
}
}
You can use grid-gap in your CSS. Something like this:
grid-gap: 15px;
Just remove the margin-bottom: -10px from your code and add grid-gap as per your need.
I am about to start a large, design oriented website that just has to be pixel perfect and as good as possible.
The problem is how to keep consistent spacing between elements in a container like this:
Currently I create all containers with
padding: 40px 40px 30px and every element with margin-bottom: 10px;
This solves the problem nicely, but every element, including headings, has to have exactly 10 pixels below itself and zero pixels above itself.
Currently I also use https://github.com/kiskadigitalmedia/kiskabricks_wedgecss (div with set height) to create additional vertical whitespace if the design calls for it. Like here:
This is the code for the above example:
<div class="card">
<h1>Heading 1</h1>
<p>Paragraph text</p>
<div class="wedge-2x">
<a class="btn">Button</a>
</div>
Does this approach make sense? Is there any better way to guarantee consistent spacing of elements inside a container? Any input appreciated.
I would do it like this:
<div class="card">
<h1>Heading 1</h1>
<p>Paragraph text</p>
<a class="btn">Button</a>
</div>
CSS:
.card {
padding: 40px;
box-sizing: border-box;
}
h1, p {
margin-bottom: 10px;
}
.btn {
margin-top: 20px;
display: inline-block;
}
If you want for example a 10 pixels margin above & below your elements, an option could be something like this. All the elements inside the class="card" will be affected by the same margins.
.card{
padding: 40px;
}
.card h1, .card p, .card .wedge-2x, .card a{
margin: 30px 0px;
}
It depends on how much flexibility you want to have.
your solution looks like a good start. maybe try and use siblings selectors too?
so in scss you'd have something like:
.card {
padding: 40px;
h1 ~ p,
h1 ~ a { margin-top: 10px; }
}
Or use + instead of ~ if you want a more specific HTML structure.
Or you could rewrite this using margin-top for all elements except for the first one, by using :first-child { ... }
I am working on a blog site using WordPress and Susy grids. There is a <p> tag (with mild profanity) near the top of the page (link) with padding-top: 4em. Somehow this padding is slipping up under the previous two siblings, an <h1> and a <div>. The html is as follows:
<h1 class="entry-title">A Manifesto, of Sorts</h1>
<div class="entry-meta">
<span class="posted-on"><time class="entry-date published updated" datetime="2015-11-22T02:07:31+00:00">November 22, 2015</time></span> </div><!-- .entry-meta -->
</header><!-- .entry-header -->
<div class="entry-content">
<p id="manifesto">F--- Berlitz. F--- Rosetta. Do it yourself and do it in style.</p>
The style on this element is as follows:
#manifesto {
text-align: center;
font-style: italic;
font-weight: 300;
padding: 2em 0 1em 0;
}
I can tell, using the Chrome inspector, that the <p> is both really tall and that the padding-top (the green-highlighted area in the inspector) is way above the <h1> sibling. I am stumped... I tried margin-top and the same issue happened. Can anyone explain what is going wrong? My styles are not too complicated, I don't think, so I am not sure what could be conflicting. Any help would be very much appreciated.
Thanks,
Dave
In main.css:457,458:
header {
width: 100%;
float: left;
margin-left: 0;
margin-right: 0;
}
There is a float: left; on the header. This effectively takes it out of the normal flow of content. Either stop floating that header element, or do a clear after it.
Try:
.entry-content {
display: inline-block;
}
I have a HTML document with inline CSS that my professor asked to have the CSS within the head tag and have the same rending from the original HTML with inline CSS. I think I'm done but somehow the <hr> within the HTML with inline CSS looks thicker than the other one.
I already tried adding a height: declaration property but it renders even thicker than I want.
Original HTML: http://jsfiddle.net/2k66T/
Modified HTML: http://jsfiddle.net/dd63m/
Edit: Here are the instructions from the professor;
Write a CSS document in order to define the style of the following web
page (I refer this to as "Original HTML") in a right way. Add and erase in the original
page everything you think that is necessary. Use the on-line validator
of the World Wide Web Consortium to be sure that your work fulfills
the standards.
Real question is... why are you using HR?
Let's render a border on the div wrapping your logo image.
Have a fiddle! - http://jsfiddle.net/dd63m/11/
Updated fiddle - http://jsfiddle.net/8VTd8/3/
I have given the div wrapping your logo an ID of logo. I removed the br break tags, we can apply margins in the CSS. The font tag is no longer used.
HTML
<h1>MyTSC</h1>
<div id="logo">
<img src="./img/TSCLogo.jpg" alt="TSC">
</div>
<h2>My courses for Fal 2013</h2>
<ul>
<li>COSC 4330 Computer Graphics</li>
<li>IMED 1416 Wed Design I</li>
<li>ITNW 2413 Networking Hardware</li>
</ul>
The logo div is currently 300px wide, change to what you want. Note: margin: 0 auto; essentially this is centering your div. margin-bottom is applied to create those extra spaces. The border is applied to your logo div giving a consistent line across browsers.
CSS
body{
background-color: grey;
color: white;
}
h1{
text-align: right;
margin-bottom: 30px;
}
div{
text-align: center
}
ul{
font-style: italic;
}
#logo { width: 300px; margin: 0 auto; border-bottom: solid 1px #FFF; }
#logo img { margin-bottom: 30px;}
add background: white; in your css not color:white
like this
hr{
width: 50%;
height: 3px;
background: white;
}
They all have the same height, the one with the default color(no color specified) has a gradient effect so it looks a little thin.
Code for the Test fiddle
<hr width="50%" color="black">
<br />
<br />
<hr>
<br />
<br />
<hr id="test">
Js Fiddle
I need your help - I have this CSS and HTML; I need the text to align to the right of the image. But for some reason, they keep pushing to the bottom of the image. What I'm looking for infact is to have the details next to the image in a grid from left to right.
Here's my code
<html>
<head>
<style type="text/css">
#container { font-size: 12px; font-family: 'Lucida Grande',Verdana,sans-serif; text-align: center; }
#container a.name_link{
text-decoration: none;
color: #8E190B;
font-weight: bold;
padding-bottom: 8px;
}
#image { width:100px; height:104px; border: 2px solid #e9e3dd; float:left;}
#text { padding-top: 5px; padding-bottom:5px; }
.horizontal_banner {float:left; margin: 2px; padding: 4px 2px 10px 10px; }
</style>
</head>
<body>
<div class="horizontal_banner">
<div id="container">
<a href="details.php?id=42">
<img src="uploads/Lisa.jpg" id="image" title="Lisa"/></a> </div>
<div id="name_container">
<a class="name_link" href="details.php?id=42">Lisa</a> </div>
<div id="text">Not available</div>
<div id="text">Not Specified</div>
<div id="text">Female</div>
</div>
<div class="horizontal_banner">
<div id="container">
<a href="details.php?id=23">
<img src="uploads/Lucky.jpg" id="image" title="Lucky" /></a> </div>
<div id="name_container">
<a class="name_link" href="details.php?id=23">Lucky</a> </div>
<div id="text">Employed</div>
<div id="text">25 Years</div>
<div id="text">Male</div>
</div>
</body>
</html>
Any help will be greatly appreciated.
To do so, you need to specify a fixed width to .horizontal_banner . 200x worked for me when I tried your example.
Something like this? http://jsfiddle.net/CvZWG/
I added new rules to .horizontal_banner to make them float left. Also, you're using the text id on divs multiple times in your HTML. IDs are supposed to be unique, if you want to use it multiple times you should use class instead of id.
You have a number of options depending on how long the text is.
However, looking at your code I would suggest... you kill all those id's and make them classes, the interpreter balks at multiple id's with the same name, that's issue number 1.
Issue 2, float: the to the left, since it's a block element, and give it a height and width. It's good practice to give anything that is floating an height and a width so the browser knows what it's working with. Don't forget clearance for margin and padding, you might want to consider some reset.css rules if you haven't set that up yet. http://sixrevisions.com/css/css-tips/css-tip-1-resetting-your-styles-with-css-reset/
Issue 3, you might have to go as far as floating those "text" divs right, although you might want to consider a or for this situation since all that data looks the same and will be a child of the same class. http://www.codingforums.com/showthread.php?t=186697
Good luck.