How to center images horizontally with text? - html

I am working on a site but the centering of my images horizontally in the footer isn't going very well.
When you make the screen smaller then 620px or something like that, then I want to center the text. But also the images.. With the images I mean the 5 icons in the third table and the picture in the fourth table.
If you try to decrease the width of the screen you will see that the images are not perfect aside the text.
So my question is.. How can I center the images horizontally with the text together when the text is aligned in the center?
Here is my footer: https://jsfiddle.net/ThomasPereira/L7dz7d4b/
I think that my mistake is here under -->
#media screen and (max-width: 623px) {
#footer #group {
padding-left:0px;
max-width:100%;
}
#footer {
height:1150px;
}
#footer #group #button {
text-align:center;
}
}

UPDATED
I just edited your fiddle a bit and managed to achieve what you wanted
https://jsfiddle.net/L7dz7d4b/2/
#media screen and (max-width: 623px) {
#footer #group {
padding-left:0px;
max-width:100%;
}
#footer {
height:1150px;
}
#footer #group #button {
text-align:center;
}
#footer #group a #icon {
width: 20px;
height: 20px;
margin: 5px;
float:none;
}
.opmaak{
display:flex;
margin:0 auto;
width:100px;
}
}

Try to make images display:inline-block instead of float:left
Smth. like:
.opmaak a img {
display:inline-block;
vertical-align:-10px; /* value to nicely show img along text, */
}
P.S. You should have only unique ids. Use class instead of id if you have two elements with the same id.

Heres a simple guide
try to use classes rather than ids for things you need to use more than once. Using inline-block is very helpful, but keep in mind, things can get pretty messy if your css isn't good. For example, 2 inline-block elements will not align correctly if one has text, and the other doesn't.
Just some things to keep in mind.

Related

Avoiding blank spaces in vertical blocks of a website

I'm trying to understand how to change a small thing in a website, but I can't figure out how to do it.
I have a grid of articles organized in two columns, and I would like the various blocks to be separated avoiding the blank space as in figure http://i.stack.imgur.com/tNCFd.png
But I don't know which kind of properties I should set.
EDIT - Clarified answer (to clarified question in comments)
There's a rule in the parent theme:
#content .post { margin-bottom: 12px; }
You need to override this rule in your child theme and set
#content > div.articolo .post { margin-bottom:0; }
ORIGINAL ANSWER
First off, I strongly suggest that you don't just throw a heavy jQuery library (i.e. masonry) at a project that can be fixed with simple CSS.
Secondly, from the code in your comments - which is this:
#content div.articolo { display:inline-block; clear:none; min-height: 10px; }
#content > div.articolo:nth-child(even) { width:48%; float:left; clear:both; }
#content > div.articolo:nth-child(odd) { width:48%; float:right; }
#content > div.articolo:first-child { width:100%; float:none; clear:both; }
You should change it to this:
#content div.articolo { display:block; clear:none; min-height: 10px; }
#content > div.articolo:nth-child(even) { width:50%; float:left; clear:both; }
#content > div.articolo:nth-child(odd) { width:50%; float:right; }
#content > div.articolo:first-child { width:100%; float:none; clear:both; }
Note the only things that I changed were the width (changed to 50%) and I changed display: inline-block to display: block
display: inline-block preserves whitespace (converts many to one) in the markup, so if you have a space in your markup after a closing div that is display: inline-block, you'll see a space in your browser. Chances are, that is why the developer set the widths to 48%, to (poorly) account for the fact that there was a space appearing after each article block (because it was display: inline-block) meaning that each block couldn't be set to 50% width, because then they wouldn't appear next to each other (because 50% + 50% + a space > 100%)
Try setting the height of each article to 'auto' with suitable margin-bottom. You'll still get some space below where two articles height are less than the corresponding articles in the other column.
Look at the item columns on http://www.ebuyer.com/ - this illustrates the effect.
Pretty difficult to say from just an image. If the margin is in the html elements, you can try to set margin and padding to 0px; if the whitespace is in the bitmaps, crop them.

Center inline-block Div not working

So I'm trying to create a drop down menu with the select and options elements that displays when the device width gets small enough. My problem is I can't center the div that the select element is contained within for some reason (the div id is "navbar2"). It just hugs the left side of the screen. Can anyone see my mistake here?
#navbar2 {
display:none;
}
#media (max-width:380px) {
#navbar2 {
display:inline-block;
width:80%;
margin-left:auto;
margin-right:auto;
border:1px solid red;
}
#navbar2 select {
width:40%;
}
}
So I figured this out. Apparently the "auto" trick doesn't work on inline-block elements. So I switched the "display" to "display: block;" and it centered the div horizontally.

can't get bootstrap to centre right

I am building a joomla 3 template so I have to use bootstrap 2. I am a bit new to BS and want to learn.
There are 4 sizes, and 3 of them are working well. I want the third smallest to go into each block being full size (like the smallest) but I am having problems getting things centered. I have used firebug to copy over the styles for row, span and container - but something is wrong.
the content is in a .span2 and I have this css
.row {
margin-left:0px;
}
.container {
background-color:#F0FA5A;
}
.span2 {
width:100%;
float:none;
margin-left:0;
display:block;
box-sizing:border-box;
}
here's a ss:
As you can see the container (yellow) is centered, but the content isn't.
So if I put the .row margin-left to -20px to pull it back the row becomes too wide thus:
If someone could suggest what I need to do please to get it right
I have also tried setting the container width to auto, with margins:auto - now its perfect, excep
You can see it at www.fct.ee-web.co.uk
thanks
In bootstrap.css you can see
[class*="span"]
value :
margin-left: 20 px;
you can edit it or override it with !importion;
put a margin-left:0 on the mainContent when have the proper size
#media (max-width: 979px) and (min-width: 768px) {
.mainContent {
margin-left:0px;
}
}

CSS styling, float:right and keeping the left text to a restricted width

I'm trying to replicate the following table of contents:
You can see my attempt here and see the problem: I don't know how to keep the chapter titles restricted to a specific width so that they don't wander over to the page numbers. I've tried things like width:250px and margin-right:30px; and padding-right:30px;, but to no avail.
Here's some of the code:
.conts {
font-size:80%;
text-align:justify;
text-indent:-1em;
margin-left:1em;
margin-bottom:1.5em;
}
<div style="text-align:center;font-size:80%">CHAP. IX.</div>
<div class="conts"><span><em>Of the different Degrees of Virtue and Vice</em>, <em>and the methods of estimating them</em>. <em>Of Difficulties attending the practice of Virtue the use of Trial and Discipline in forming reasonable Beings to Virtue</em>, <em>and the Essentials of a good and bad Character</em>.</span><span style="float:right;">p. 200</span>
</div>
Any help would be appreciated.
You should use p to wrap the text instead of a span element, assign some fixed width to p and float that to the left
Demo
.conts {
font-size:80%;
text-align:justify;
text-indent:-1em;
margin-left:1em;
margin-bottom:1.5em;
width: 600px;
}
.conts p {
float: left;
width: 500px;
}
.conts span {
margin-top: 10px;
}
If you want to position the number at the end of the line, use position: absolute; wrapped inside position: relative; container.
Demo 2
First. change all this code <span style="float:right;"> Page number here </span> into <p>Page number</p>. then change your CSS like this.
.entry {
width: 450px;
padding-left: 90px;
}
strong {
font-variant:small-caps;
font-weight:normal;
}
.conts {
width:100%;
}
.conts span {
float:left;
width:80%;
font-size:80%;
text-align:justify;
text-indent:-1em;
margin-left:1em;
margin-bottom:1.5em;
}
.conts p {
float:right;
width:10%;
font-size:80%;
margin-top: 0px;
}
Last, add <br clear="all"/> after <p>Page Number</p>. hope this help :)
See Demo Here
Try adding a padding-right:100px; to the contents and margin-right:-100px; to the floated page number. That should make sure the full contents are correctly made to stay a certain width while pulling your page numbers out of that space and into the right margin.
wrap all of the chapters up into one main div. Float that left, width 80% (or whatever works). then wrap your page numbers into a second div, and float that right with a width of 20% or less, depending on your margins. MAKE SURE YOU GIVE YOUR WRAPPER DIV (or whatever div you wrapped the entire code in) A WIDTH OR THE WIDTHS YOU ASSIGN TO INSIDE DIVS WILL NOT WORK.

CSS Footer with responsive css

i am trying to create a CSS Footer with this CSS:
.footer {
width:100%;
background:#666666;
clear:both;
color:#FFFFFF;
}
.footer-container {
display:inline-block;
width:80%;
margin: 0 auto 0 auto;
}
.social_links {
float:left;
list-style:none;
display:inline;
}
.footer_text {
text-align:center;
}
.footer_logo {
float:right;
}
i want 3 columns, the left one fairly small just for facebook and twitter social icons displayed next to each other (inline) the middle column for text so that one larger and then the right one just for a small logo
i am trying to make it responsive too so as the page gets smaller, it goes in order:- the left column (social links) / middle column (text - aligned center) / the logo down the bottom
here is a fiddle with what i currently have but i cannot get it working as above.
http://jsfiddle.net/eYwsm/1/
If you dont want the columns to be rows in mobile size this will do the trick:
http://jsfiddle.net/eYwsm/2/
.footer_text has overflow: hidden so it will take the remaining space between the floating elements.
I would use a media query (http://css-tricks.com/snippets/css/media-queries-for-standard-devices/) and have the elements display changed from inline to block at a certain width. For example, using this in your CSS
#media screen and (max-width: 480px)
{
.social_links, .footer_logo
{
display: block;
}
}