HTML/CSS - How can I change the spacing or add whitespace so the boxes are equal? - html

I'm new to the frontend and work out of the backend. I found a layout I am interested in using however noticed that when typing in these boxes if the text length isn't equal the sizing of the box changes for one of the boxes in the row and not all.
I want them all the be sized equally so if one box is using one line of text and the others two lines, the one line provide white space to match the size.
E.g.
I'd like all the boxes on that row to add in the whitespace so the boxes are equal in size so I don't get the layout issues since in the pic above.
Like this:
How do I change the css for the boxes to automatically resize all the boxes and not just one?
This is the layout I am using: http://adapt-trackers.blogspot.in/

It seems as though right now their spacing is determined by the margin/padding/border values. Try setting a height and width so that they are all the same.
For example:
#selectable li { margin: 3px; padding: 1px; float: left; width: 165px; height: 160px; font-size: 1.5em; text-align: center; }

try this (courtesy of CSS the Missing Manual):
<div id="gallery">
<div class="figure">
<div class="photo">
<img src="../images/carpet.jpg" alt="Carpet Grass" width="200" height="200" /> </div>
<p>Figure 1: Even the carpet-like <em>Carpetorium Pratensis</em> requires mowing. </p>
</div>
In this example, the gallery div wraps all the images together; the photo class wraps each image and caption together. Here's the CSS:
.figure {
float: left;
width: 210px;
margin: 0 10px 10px 10px;
}
.photo {
background: url(drop_shadow.gif) no-repeat right bottom;
}
.photo img {
border: 1px solid #666;
background-color: #FFF;
padding: 4px;
position: relative;
top: -5px;
left:-5px;
}
.figure p {
font: 1.1em/normal Arial, Helvetica, sans-serif;
text-align: center;
margin: 10px 0 0 0;
height: 5em;
}
Also, there's several gallery frameworks that you could use instead. Or stag some code from dynamicdrive.com

I'd give your tag for ... a minimum height.
add class to your anchor tags:
Link:
...
css:
.link-title{
min-height: 150px;
}

Related

I am trying to get the text to appear on the right hand side of the image, and for the actual image box to be a lot slimmer that it currently is

This is the css I have atm but it is all going chaotic and this is how the section of the page looks:
[![
#firstborder{
border: #3063A5;
border-style: double;
font-size: 9.5px;
font-family: "Palatino Linotype", serif;
padding-left: 5px;
float: left;
margin: 0 20px 20px 0;
}
.linguistics_paragraph{
margin-left: 385px;
padding: 3px; margin-top: 5px;
top: 40px;
font-family: "Palatino Linotype", serif;
margin-right: 3px;
margin: 0 0 10px 10px;
float: right;
}
]1]1
To make the image box slimmer I would suggest using the max-width property and setting it to your desired width so it never gets any bigger than that.
I can make a code snippet but as far as your text issue, are you trying to get the text within the bordered box? Also what is your desired outcome for the legend?
I'm gonna answer this question on a conceptual basis as you don't have your HTML provided
So as you said everything gets messy when you change the width of the browser therefore
we have to first work on making it responsive. So just go to your Html file and make a div wrapper or container that would hold both of your image and the paragraph tags
for example, something that would look like this:
<div class="container">
<img src="files/exampleimg.png" id="pic">
<p id="text">This is something</p>
</div>
Now in your CSS file remove the margin-left or margin-right you used to position the image and the paragraph tags and use flex or grid or anything similar to make it responsively positioned, I'm gonna go with flex so here it goes:
.container{
display:flex;
justify-content: space-between; /*putting img to left and paragraph to right*/
}
#pic {
padding-left: 50px; /*as per your requirement*/
}
#text {
padding-right: 50px; /*as per your requirement*/
}
and that's pretty much it for the responsive part, all we have to do now is make the image box slimmer, so for that do this:
#firstborder{
border: 1px solid #707070; /*this would make it slimmer but play with it to find out what suits best*/
}
you change the 1px to 4 px its gonna get thicker and you crank it down and it would get slimmer, there you go, now you have a responsive page and your image-box slimmed up.
and oh for your legend part add this to your HTML
<img src="files/legend.png" id="legend">
CSS:
.container{
display:flex;
justify-content: space-between;
position: relative; /*binding up the legend with container*/
}
#legend {
padding-left: 50px;
position: absolute; /*stiching the legend to that pic*/
top: 40px; /*as per your requirement*/
}

Links with images do not stay in middle

So, I got set of links set up like this. Apologies for bad names, but to keep it easy to understand, I chose to not to use real paths/names. However, all paths check out in when page is shown/used.
<nav>
<div class="center">
<img src="folder/image1.gif" alt="">
<img src="folder/image2.gif" alt="">
<img src="folder/image3.gif" alt="">
</div>
</nav>
Now, I want each image stick to each other, so that they form a one long bar. With the current set up, they all line up in the middle of the page in one row. However... there are spaces in between each. Here is the CSS:
.center {
margin: 0 auto;
text-align: center;
display: block;
}
a.navigointi
{
float:left;
margin: 0px;
padding: 0px;
}
img.navigointi
{
margin: 0px;
padding: 0px;
border: 0px;
}
However, if I designate images as navigointi class... they do stick together, forming a one long bar, but at the same time, it breaks the centering. All images float to left side of the screen. Even if I remove all content from the img.navigointi, so it becomes empty style, it still remains the same. If I don't give the images a class, they return to the middle, but once again with the spaces in between them.
Any idea what is causing the centering to break?
Here's a FIDDLE.
The line that removes the single space between the anchors is font-size: 0px;
(found on CSS-Tricks)
CSS
.center {
margin: 10px auto;
text-align: center;
display: block;
border: 1px solid black;
font-size: 0px;
}
.navigointi{
margin-left: 0px;
padding: 0px;
}
img
{
margin-left: 0px;
padding: 0px;
border: 1px solid red;
}
If I understand, you should use display: inline instead of float: left.
Here an example : http://jsfiddle.net/YTn2b/

Use CSS to position elements within a DIV

I admit, I'm not that good at CSS. Must be my lack of design skills.
So I am trying to accomplish four small tasks.
Move the time box (i.e '01:04' and '12:13') so it floats to the right top edge of the image?
Move the description of the workout to display to the right of the image beneath the time box and the routineID?
Allow the bottom border of class 'routine' to always be right beneath the image just like it is to the top of the image.
keep class 'routine' the same size even if more text in description is added. I want every 'routine' to have the same width and height dimensions.
I have everything layed out here: http://jsfiddle.net/n2learning/xMsrN/
Sorry to be that annoying guy with four questions in one question. Any help is appreciated!
Here is an updated jsfiddle link: http://jsfiddle.net/n2learning/xMsrN/22/
Follow up questions and comments -
The 'workout description' is still jacked up. Trying to get this to display beneath the top row, which includes the 'time' and 'ID'. The top row will also (eventually) include small image symbols.
I just noticed that the image sizes are different. I tried modifying '.routineImage' to give it a width and height property, but doing that screwed things up. How/where do I standardize the size of each image? (the images are coming from youtube and other video sources)
<ul id="routinefilter">
<li class='routine' data-id="15">
<div class='routineImage'><img src=http://img.youtube.com/vi/UheCchftswc/2.jpg></div>
<div class="routineTimeID"> <!-- added wrapper to keep it a single row -->
<div class='routineID'>16</div>
<div class='routineTime'>01:04</div>
</div>
<div class='routineDesc'>Use lighter weights on a barbell due to higher counts</div>
</li>
</ul>
CSS
#routineframe {
height: 400px;
border: dashed;
font-family: Arial,helvetica,sans-serif;
cursor: pointer;
width: 60%;
overflow: auto;
}
#routinefilter {
list-style: none;
clear: both; /*keeps each <ul> seperate*/
}
.routine{
background: #F4F4F4;
color: #41383C;
font-size: 18px;
border:2px solid #666;
margin:5px;
padding:5px;
width: 95%;
overflow: hidden; /*allows this to contain the floats*/
}
.routine .routineImage{
position: relative;
float: left;
display: inline;
margin-left: auto;
margin-right: auto;
}
.routine .routineTime{
position: relative;
top: 0;
float: left; /*this was floated the wrong way*/
margin-left: auto;
margin-right: 3px;
border: 1px solid #666;
background: white;
color: navy;
}
.routineTimeID { /*class added to keep the description from being in between the two elements*/
width:140px;
float: left;
}
.routine .routineID{
top: 0;
float: right;
margin-left: auto;
margin-right: auto;
border: 1px solid #666;
background: white;
}
.routine .routineDesc{
top: 0;
margin-left: auto;
margin-right: auto;
font-size: 16px;
}
I tried to notate all the changes I made and why. I think i got all of them...
For the last question, though, you can't do this with CSS. As I understand it, you want the text size to automatically shrink if more text is added? That will have to be done with JavaScript, solution here

How to align these two elements inside a div

I am having a little trouble aligning two elements inside a div (the quote and the arnold pic).
Here is what it looks like:
<div class="container">
<div id="quote">
<p id="tagline-quote">"As a personal fitness trainer, I'm asked on a weekly basis where the best place to buy supplements is, and my answer is always bodybuilding.com"</p>
<img id="q-image" alt="" src="http://www.cheapestsupplementsonline.com/wp-content/uploads/2012/03/arnold_schwarzenegger.jpg"></img>
</div> <!-- end #quote -->
Here is the css:
.container {
margin: 0 auto;
position: relative;
text-align: left;
width: 960px;
}
#quote {
padding: 60px 400px 20px 13px;
text-align: center;
}
p#tagline-quote {
color: #777676;
font-family: Georgia,serif;
font-size: 20px;
font-style: italic;
line-height: 30px;
text-shadow: 1px 1px 0 #FFFFFF;
}
#q-image{
}
This is a textbook "css floats 101" question. Oh, wait, I thought that was original but that's exactly what the article on alistapart is called. You can position the image inside the quote/paragraph and float it right - that's pretty much what the floats were made for before semantic layouts took over :)
<div class="container">
<div id="quote" class="clearfix">
<img id="q-image" alt="" src="http://www.cheapestsupplementsonline.com/wp-content/uploads/2012/03/arnold_schwarzenegger.jpg" />
<p id="tagline-quote">“As a personal fitness trainer, I'm
asked on a weekly basis where the best place to buy supplements is,
and my answer is always bodybuilding.com”</p>
</div>
</div>​​​​​​​​​​​​​​​​​​​​​
For CSS, I've thrown out some of the original padding :
#q-image{
float:right;
/*add some margin so that there is space between text and photo*/
margin-left:10px;
}
Now the issue that you were having with KodeKreachor's code was seemingly incorrectly "garbling" the divs below and you probably saw the quote container looking shorter than it should be. The workaround is using a "clearfix" that expands the parent container so that the floated element can fit inside. Remove it from the code and see how the (temporarily) highlighted container acts.
On a side note... try adding more paragraphs and move the image into one of them. Now that "odd" behaviour makes perfect sense - paragraphs start flowing nicely around that floated image without massive gaps.
Fiddle: http://jsfiddle.net/EvdV8/ Also: proper quotes. Also: img is a self-closing element so original markup was not valid.
If you're talking about side-by-side, you use a combination of "float: left;" and "display: inline-block" to force them next to each other.
.container {
margin: 0 auto;
text-align: left;
width: 960px;
}
#quote {
padding: 60px 400px 20px 13px;
text-align: center;
display: inline;
}
p#tagline-quote {
color: #777676;
font-family: Georgia,serif;
font-size: 20px;
font-style: italic;
line-height: 30px;
text-shadow: 1px 1px 0 #FFFFFF;
position:relative;
width:400px;
display: inline-block;
}
#q-image{
position:relative;
float: left;
}

Keep website sizes the same

Hey guys I am having trouble with keeping things aligned on my website. Here is an example of what the website should look like:
Now, here is where it makes unaligned.. When I resize the window to be smaller, the Text shifts over like so:
Currently these are the css attributes applied to my tag which is on the text.
#header_title_container {
width: 1000px;
margin: 0px auto;
padding-left: 85px;
padding-top: 50px;
}
#header_title {
font-size: 33px;
color: #FFFFFF;
font-weight: bold;
}
What would the proper way to approach always having "Title" aligned with the corner of the darkest gray box?
Thanks.
Because your title container has padding inside it, the text "Title" is kept at least 85px from the screen edge. Because it's left-aligned, that means its left-hand edge is always at 85px.
So, when your sidebar gets smaller than 85px, the text cannot align with it.
You could fix this by fixing the size of the sidebar, by eliminating the padding-left directive and replacing it with an element sized as the sidebar is (or replacing it with the same amount as your sidebar width!), or by setting min-width on the sidebar.
Is this the kind of result you are after?
http://jsfiddle.net/2ScZZ/5/
html
<div id="container">
<div id="header_title_container">
<div id="sub_header_title_container">
<div id="header_title">
Title
</div>
</div>
</div>
<div id="middlebit">
</div>
</div>
css
#container {
background-color: lightgray;
}
#header_title_container {
width: 100%;
background-color: black;
}
#sub_header_title_container {
width: 900px;
margin: auto;
padding-right: 20px;
}
#header_title {
font: 33px verdana;
color: white;
padding: 50px 0 10px 0;
}
#middlebit {
margin: 0px auto;
width: 900px;
height: 100px;
background-color: gray;
}