Getting everything in bootstrap container to stay a fixed width - html

I have a bootstrap container with a bunch of form data in it. I think the width of the container is 970px regardless of how wide my window is. But when I size my window down to a much smaller size the form data inside gets pushed around and moved. Is there a way to keep the containers data all set a fixed width so the elements inside don't shift around when I resize the window?
I tried settign the min-width but that didn't do anything.
.container {
min-width: 970px !important;
border: 1px solid black;
}

If you're using columns inside the container, don't forget they have a percentage width, so you'll need to fix width those elements.
I can't be for sure without seeing your code, so perhaps post a JSFiddle and I'll edit this with a proper answer.

Why are you using fix min-width? It is the reason form data moved. Try to use col-md-4 or col-xs-5 etc classes or percentage width.

I'm not sure what are you trying to achieve as it seems like you are going against the responsive framework, which makes me wonder why you use bootstrap at the first place?
Besides, I think this meta tag post will help you achieve such a thing by using meta tag
<meta name="viewport" content="width=970">
and you should change .container to .container-fluid.

All information needed is here: http://getbootstrap.com/getting-started/#disable-responsive
And here's an example of how it works: http://getbootstrap.com/examples/non-responsive/

Related

Border-Box resizing out of view

so lately I came up with this problem: My wrapper has a max-width of 1440px and I want to add a 10px solid border around it. When I add it the border just takes 10px of the max-width and is being displayed, everything's fine. But I want that the border does not take anything of the max-width, I want to display the 10px of the border by 1440px +
One solution would be media queries, I know that, and this also works fine. I am just wondering if there is a solution without adding a seperate wrapper and without media queries so the border just appears, when you resize your window over the 1440px and simply is cut off when you resize the window under 1440px.
Just for anybody who is wondering. I have a boxed layout and want to limit the content area for larger screens, but whish to use full-width on smaller screens.
Thanks! :-)
You could possibly add a position relative to the container and have a z-index set. Then have a pseudo item like :before have position absolute and a negative z-index with the height and width set to match the parent. This will put it behind your content and if you have the border added to it you should be set. Probably will need overflow-x:hidden on the body so it doesn't create a scroll bar. I'll create the code for this soon for reference.
Or a less complex option would be
outline:10px solid blue;
Outline goes outside of an element even with box-sizing of border-box.
This did it, the next thing I see is how to get a border-radius with the outline. I remember a trick with box-shadow. I will search for it, since the original question wis solved. Thank you very much! :)

Why does this CSS produce such a huge layout when displayed on a smartphone?

I have this CSS: https://cal-linux.com/styles/tutorial.css
And a sample page that uses it: https://cal-linux.com/tutorials/gswc++.html
When I display this on a smartphone (or when I check it through Google's Mobile friendliness verify service), the layout looks huge (badly cropped, instead of reduced to fit the smartphone's screen.
I only use proportional measures (for example, outsidecontainer's div has width 80%, inside right-most column has min-width 25%). I'm placing Google Ads in there, but it's a "Responsive" add, which is supposed to adapt to the page's available size and layout.
Any tips on this? I figured posting the actual links to the pages might be ideal; but please let me know if a "minimal" instance of code that reproduces the problem would be preferred.
Thanks,
Cal-linux
There are a few things I note here:
You use display:table-row and display:table-cell a bit too much. Those don't respond as well to the resizing especially if you have not specified the width of each item. Instead either use floats with a clear:both on the container's :after pseudo-element or inline-block. Either way you should define percent widths for the containers.
Your css has a lot of white-space:nowrap but doesn't use overflow:auto which forces the element to not resize the content and just stretch its parent container.
Aside from that a few places I see a fixed px width which makes it more difficult to resize. It doesn't seem to be your ads. Although google's script does throw an error about trying to put an ad in an 86px x undefined space. You can set a fixed height or at least a min-height to give the script an idea of how big an ad should be placed there.
The easiest solution is to incorporate bootstrap to do the heavy lifting of setting up a grid for what you want.
You can basically do your two column style like so:
<div class="container-fluid">
<div class="left-col col-md-11">
<!--- ALL YOUR CONTENT HERE //-->
</div>
<div class="right-col col-md-1">
<!---Google Ads go Here //-->
</div>
</div>
If you want to stick with your own style, by using the code inspector in chrome I was able to get to the following result when resized:
I made the tablerow class be a standard display:block
The first column was set to width:75%; display:inline-block;
The second column was set to width:25%; display:inline-block;
The autosize elements changed to display:block;max-width:100%; overflow:auto;width:auto;padding:0
The div.code blocks were changed to display:block;white-space:nowrap;width:auto;
Everything else stays the same pretty much. That should fix it, however you should note that frameworks like bootstrap help out with mobile sites by making the page columns collapse and go one ontop of another for mobile browsers so that they get maximum space.

Content container not resizing to fit content

I've been banging my head against a wall trying to figure this out; http://nicklemmon.com/lily
For some reason the height of the .content div won't adjust to fit its contents! I can make the height of .content greater than 100%, but that kind of defeats the purpose of a fluid layout. This is just a random site I was working on to learn more about CSS animations, yet I've run in to this silly barrier on the way.
Help!
overflow:auto should do the trick for you.
.content{
overflow:auto;
}
you have a height of 100vh, remove it and you should be fine.
Update(making left column height equal to right column height)
As it appears, there seems to be no straightforward way to adjust left column to same height as right column using pure CSS, you can do a workaround in a number of different ways, best way I would suggest is to use Javascript/jQuery.
//HTML
<div class="moving-right big-lefty col-md-3">
</div>
<div class="big-righty col-md-9">
</div>
//jQuery to use on document ready.
$(".big-lefty").height($(".big-righty").height());
you might want to try another CSS solution that did not work in your case when I tried it on chrome, using inspector. you might want to play with it.
Have .content as display:table-row and .big-lefty and big-righty as display:table-cell

items inside div not resizing

I'm having a great deal of trouble in getting all items inside a specific Div to resize within that Div, depending on the Div's width (Which is currently width:100%).
I've tried using the display:inline-block but that doesn't seem to work. There has to be something that will work? Basically I have a Div Wrapper that is width:100% and then a Div Container inside that which is a specific width.
The background of a Div inside all of those, has a background image, which I need to automatically resize according to the width. The site resizes down so it is Mobile friendly, which is where I'm getting the issue with the background image being huge still.
The link to the page in question, is here - Link to Page
The below code, is the bunch of Divs mentioned above:
#content-home {
float: left;
min-width: 100%;
padding: 40px 0px;
}
.home_container {
margin: 0 auto;
width: 320px;
}
Hope you guys can help out at all! Just as a warning, it's a WordPress site too but this is specifically a CSS issue. I'm not too sure if there is a Javascript or jQuery function, able to handle this idea?
Thanks!
Mark
It seems like the problem is that you're mixing % and px units for calculating the widths. Try using only % for both widths.
If that isn't the problem, then try using just "width" instead of "min-width". It seems like the "min-width" property might be the issue.

HTML element percentage height problem

i made myself a Speed Dial-like homepage with links I visit the most.
Now, i made it elastic, so when browser window is narrowed horizontally, the boxes getting narrower too.
What I want is that when browser window is narrowed vertically, that boxes get narrower again.
I tried with several percentage height rules but it didn't work, need help.
Here is the page I'm working on its one-file page so CSS is not separated.
http://www.purplerspace.com/dl/
You have to add the height percentages to almost all the divs if you want it to work. Add height: 100% to html, body then the wrappers and also the lis and yeah, the a style too.
Don't know if it's optimal but tables for this should work. Set the table height and width to 100%. And don't forget to set your html and wrapper tag to 100% in height.