Undesired horizontal scrollbar on 5 column responsive set up

Hi
I’m using this code:
html:

<!DOCTYPE html>
<html lang="pt-PT">
<head>
	<title>Tania</title>
	<meta charset="utf-8"/>
	<link href="tania.css" rel="stylesheet" type="text/css" />	
</head>
<body>
<div class="row">
  <div class="column">
    Notícias
  </div>
  <div class="column">
    Agrupamento
  </div>
  <div class="column">
    Eça
  </div>
  <div class="column">
    Parque
  </div>
  <div class="column">
    Vasco
  </div>
</div>
</body>
</html>

the related css:

.column {
  flex-basis: 100%;
}

@media screen and (min-width: 500px) {
  .row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
  }
  .column {
    flex: 1;
  }
}

but when i try it in my real site, a get a nasty horizontal scrollbar: do you have any idea why?
i tried removing, once a time, every other block i have, but with no result

thanks in advance for any help

Since that code (by your own statement) is fine, then we need to see a page with that code thrown in to see what else is triggering the scrollbar. You gave us non offending code :slight_smile: . We need to see a full example since there are hundreds of reasons why a scrollbar could appear.

Hi
i’m sorry but i saw your answer just now, bwcause i was notified but n email, but my phone kept silent so i didnt notice it

anyway, i tried and tried

one experiment i made was cleaning the style sheet, but as soon as i introduce the 5 column code i get that bar

i’m quite afraid you’l blame my code, but remember i’m a an amateur, pls be easy on me

i’ll upload the page, when at the very bottom i have the mentioned code

i cant put the page online because i’m working from my PC and have no server (yet)

here’s the html (hope it helps)
index.html (14.0 KB)

agrupamento.css (5.9 KB)

What i found out so far:
i deleted all code except the flex grid one and in <head> commented out this:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />

so, in this way there is no horizontal scroll bar at all

Have you read the instructions for using bootstrap?
The 5 column HTML at the bottom of the page is triggering the horizontal scrollbar at desktop widths. If it is supposed to be bootstrap code, it does not follow the rules of using bootstrap. Read the instructions, they are complicated,… try again.

There is a <span> inside a <table>. That’s invalid HTML.
Any tags within a <ul> or <ol>that are outside of <li> tags are invalid HTML… including anchor tags.

Not to worry. We know the code didn’t write itself.

Take a large step toward being a professional… routinely run your code through the HTML and CSS validators - several times a day, if necessary - so you can identfy problems when they develop, not days or weeks later.

https://validator.w3.org/nu/

https://jigsaw.w3.org/css-validator/

most of my html errors i simply cant fix them or else find a way around, like, for instance, in the very top i have a logo glued to a dropdown menu; i want it all centered but i just dont know how to achieve it, hence the bad code

anyway i apreciate your recomendations and sugestions

if by any chance someone can point me to alternative to the span inside the table, or to the center align i just referred, i’d be very glad

thank you

What is the purpose of the span? Is it just to apply the class .alturacelulas?
That could be applied directly to the table:-

<table class="anuncio alturacelulas">

But, I don’t think you should even be using tables, they are not a layout tool and should not be used for that purpose, certainly if you want the site to be responsive.

I’m not very familiar with Bootstrap, but your html does not look like code that has been written to work with Bootstrap, I don’t see any ‘Bootstrapish’ classes anywhere, and I’m quite sure Bootstrap does not work well with table layouts.

1 Like

Hi,

As others have pointed out your first stop with bootstrap problems is to consult the documentation and the very first point they make about grids is that rows must always be inside a container.

Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.

You are using .row which is not wrapped in ,container and therefore the default negative left and right margins on .row trigger a scrollbar. In bootstrap the container element has 15px left and right padding which soaks up those negative margins which will stop the row element from poking out anywhere.

Add .container to your page (or .container-fluid) as directed by the instructions :slight_smile: (or don’t use .row as the container for that section and use another name).

You can’t use a framework without learning the rules of the framework or you will continually run into issues like this when you make your own classes up.

4 Likes

when i started with the idea of making a new site for my school i had no idea whatsoever about bootstrap or similar

today i read and bookmarked this: http://getbootstrap.com/css/ which made me very encouraged

you are right: the code isnt bootstrapish, but i have the menus at the bottom with a 5 column bootsrap code, and working

gonna see if i’m able to substitute the table with columns or any other visually agreable solution

as i dont still have a server (i have the pages, docs, images and so on inside a folder and use chrome to visualize them, minimizing the page to emulate smartphones and tablets :smile:, i’m not sure if its totally responsive

anyway i feel quite confident in the end i’ll be not ashamed of what i produced

ronpat recomended to validate pages: one of the very first errors was the use of:
<div align="center">
well, i must confess i knew it was wrong, but as i had spent literally lots of hours trying to find a satisfactory solution (either testing by trial and error or searching the internet) i opted to use this one

note that i’m refering to the case that has width =100% and could not find anithing suitable

anyway i’m very thankful to all of you who keep helping me

As a general rule of thumb, anything that layout, styling or visual appearance, should not be an attribute of html, it should be handled by the css.

If you choose to go down the route of using Bootstrap for RWD, that’s exactly what you need to do, study how Bootstrap works.
Though Bootstrap is not the only way to achieve RWD. :wink:

i remember i read exactly that about the div align

3 years ago i bought this book: “everithing you know about css is wrong”, from sitepoint; and i found out these days many people saying the same, which encouraged me towards using tables for layout, but as i said before, for now i’m gonna try builidng ths site 100% responsive

wish me luck

:upside_down:

Tables are html elements, thus not for layout, layout is css’s job.
Table are for tabular data only, like a train timetable or football league or w/e.
If you want multi columns or a grid-like layout, by all means use the css display: table; but never html <table>. Though I think Bootstrap has provision for those layouts anyway.

1 Like

What is the URL to your school’s current web site?

[Agrupamento de Escolas Eça de Queirós](http://www.eseqlx.net/queirosbeta/index.php)

sometimes i think i’m driving nuts
i studied how to make a very simple grid (two equal width columns) with bootstrap (in order to substitute the table i have)
now i’m able to add extra vertical space (with min-height) but then my text and image aligns at the top and i just cant find a way to vertical align it

do you have any ideas, please?

<div class="container">
	<div class="row">
		<div class="col-sm-6">
			<p class="pbold">Manuais Escolares</p>
			<p class="pnormal">Já sairam as listas dos Manuais Escolares adotados para o ano letivo de 2016/2017 na página de cada uma das escolas</p>
		</div>
	</div>
	<div class="col-sm-6">
			<img 
				class="amplia" 
				src="imagens/quadroPreto.jpg" 
				width="165px" 
				height="100px"
				alt="Quadro escolar"/>	
	</div>
</div>

my relevant css:

.amplia {/*http://stackoverflow.com/questions/18456169/show-enlarged-picture-when-mouse-hover-over-an-image*/
	border: none;
	margin: 0 auto;
}

.pnormal {
	font-size: 120%;
	font-weight: normal;
	color: #707070;
	line-height: 125%;
}

.pbold {
	font-size: 180%;
	color: black;
	font-weight: bold;
	line-height: 125%;
}

thanks in advance

What browser are you using, please?

chrome Versão 51.0.2704.106 m

here’s my current workaround:

.demo-content{
	padding-top:40px;
	padding-bottom:40px;
}

Where is .demo-content applied in the HTML? That classname is not shown in the code that you posted.

Would you consider installing Firefox on your computer? Firefox provides an easy mechanism for Zooming the size of TEXT-Only. It is often useful for testing layouts.

Have you ever started and finished a basic course in HTML and CSS? If you have not done so, you absolutely should… before you try to rewrite your school’s web site. I think you underestimate the sophistication and knowledge that went into its making. Surely the content on the site is updated occasionally… how is that done and who does it?

its a platform called joomla

its (was) mantained by a little old lady that went to retirement (actually i’m quite close too) and i was invited to substitute her[quote=“ronpat, post:19, topic:230867”]
Where is .demo-content applied in the HTML? That classname is not shown in the code that you posted.
[/quote]

as i’m constantly updating and recoding, it was missing; here it goes:

<div class="container">
	<div class="row">
		<div class="col-sm-6">
			<div class="demo-content">
				<p class="pbold">Manuais Escolares</p>
				<p class="pnormal">Já sairam as listas dos Manuais Escolares adotados para o ano letivo de 2016/2017 na página de cada uma das escolas</p>
			</div>			
		</div>
		<div class="col-sm-6">
			<div class="demo-content">	
				<img 
					class="amplia" 
					src="imagens/quadroPreto.jpg" 
					width="165px" 
					height="100px"
					alt="Quadro escolar"/>
			</div>
		</div>	
	</div>
</div>

i’m a self taught man (in regard to coding), and i find your words quite discouraging, but i’m conviced i’ll put up the site running, responsive and with few errors

i’ll keep you informed and hopefully you’ll change your mind :slight_smile:

anyway let me tell you i apreciate any constructive criticism