I am really new to coding, but I am trying to make a snake game using JavaScript (which may or may not be too advanced for my skill set considering I am having problems with this, but I am going to try lol). Anyways, I am trying to center a container on a page that will stay centered (without growing or shrinking in size no matter the window size). I need the container to stay 300px in width and centered in the middle of a page, but just grow and shrink itslef along with the words/buttons inside it (while keeping them on the same line) no matter the window size. I tried to use the align and justify methods with flexbox, but they do not necessarily work when I set the container width to 300px. I googled possible solutions and tried the padding thing using vh. Setting the padding to 30vh works for the top and bottom of the container, but the left and right sides of the container still stretch and shrink when I drag and adjust the window size. I am sure there is a simple solution to this (or maybe what I want is actually really complex), but I just can not find something that works. Any ideas?  &lt;body&gt;  &lt;div class="container"&gt;     &lt;h1&gt;Snake Game&lt;/h1&gt;     &lt;p&gt;Developed By Herman Thomas IV&lt;/p&gt;     &lt;button type="button" class="btn btn-success"&gt;PLAY!&lt;/button&gt; &lt;/div&gt;      body {     background: linear-gradient(to right bottom, blue, red);     height: 100vh;     padding: 30vh; }  .container {     position: relative;     background: white;     max-width: 300px;     border: 1px solid black;     text-align: center;  }
42
How can I horizontally center a &lt;div&gt; within another &lt;div&gt; using CSS? &lt;div id=&quot;outer&quot;&gt;   &lt;div id=&quot;inner&quot;&gt;Foo foo&lt;/div&gt; &lt;/div&gt;
56974
I want to create a toggle button in html using css. I want it so that when you click on it  , it stays pushed in and than when you click it on it again it pops out.   If theres no way of doing it just using css. Is there a way to do it using jQuery?
28788
The following code gives me an error:  \documentclass[12pt]{article} \usepackage[margin=2cm]{geometry} \usepackage [english]{babel} \usepackage{amsmath, amssymb} \usepackage{enumitem, array} \begin{document} {\begin{minipage}[t]{\textwidth} \begin{enumerate}[label=(\roman*)] {\setlength\itemindent{10pt}\item  \begin{equation*} \begin{array}{&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}}  \hline x &amp; l_{[x]} &amp; d_{[x]} &amp; l_{x+1} &amp; \mathring{e}_{[x]} \\ \hline \end{array} \end{equation*}} \end{enumerate} \end{minipage}} \end{document}   Note: for various reasons, I have to keep minipage there. For some reason, this code gives me an error when it compiles. It gives the following output:     The errors either say there is a } missing or a $ missing. My eyes don't see such a thing!
100547
I'm trying to get the bounds of an object and put a box around it.  Sounds simple right? I just encapsulate all the bounds together and use its center and size to do so.  But the problem is one corner of the box is always at the center of the scene, like a part of the object is there, unless the center of the scene is in the bounds.  This is when object is at the center   This is when it isn't  This is the code i'm using:      public static Bounds Calculate(Transform TheObject)     {         Renderer renderer = TheObject.GetComponent&lt;Renderer&gt;();         Bounds combinedBounds = new Bounds();         if (renderer != null)             combinedBounds = renderer.bounds;         var renderers = TheObject.GetComponentsInChildren&lt;Renderer&gt;();         foreach (Renderer render in renderers)         {             if (render != renderer) combinedBounds.Encapsulate(render.bounds);         }         return combinedBounds;     }
120282
It's pretty annoying that you can't center text vertically in Ps automatically, like you can in Indd. It's even more annoying that the bounding box of text can't be 'collapsed' or 'fit to text', like in Indd.  I could convert the text to shape, but then I lose coloring. I could convert to smart object, but then its not vector anymore, for when I export to pdf.  Is there a work around anyone knows of that would make it easier to center text vertically?
51888
I've been learning LaTeX and this community has been very helpful. Currently, I'm trying to set up corporate letters but as a newbie I'm encountering a  of , so I'm posting them one by one instead of putting it in the comments... maybe this helps others as well.  Anyway, I am trying to implement this  that indicates that I can use vbox to float an image to the right of my header. I almost have this working, but I now try to adjust this to get my logo to stick to the top of the page. So I want to have this at the right top of my document. This is quite difficult! When I place the vbox, it creates unwanted spacing, for some odd reason. So I can not get the logo to be at the right top, even though I 'reset' every possible margin to 0 (in my opinion). Here is my distilled code:  \documentclass[a4paper]{article} \usepackage{graphicx} \graphicspath{{./img/}} \usepackage{color} \usepackage{xcolor} \definecolor{orange}{HTML}{DD4616} \definecolor{white}{HTML}{FFFFFF} \usepackage{fullpage} \usepackage[margin=0cm, paperwidth=215.9mm, paperheight=30mm,top=0cm]{geometry} \parindent=0pt  \begin{document} \fboxsep0pt  \pagecolor{orange}   \fbox{\vbox to 0pt{\hfill\fbox{\includegraphics[height=3cm]{logo}}}}  \end{document}   I've used a full black logo for illustrative purposes. Here you can see this:    The black line is the vbox border. For some reason, it jumps down. The only way to get rid of this that I found out about is this:    Which means that I need to add:  \edef\theprevdepth{\the\prevdepth}\nointerlineskip \vbox to 0pt{...}\prevdepth=\theprevdepth   But there are two problems with this:   I get an error with I try this (Improper \prevdepth.) More importantly, I really want to understand my code at this point, and get to master the basics of positioning elements. This feels overcomplicated and I do not understand it at all.    Is there any easy way to position an image at the right top of a document?
37482
I am trying to center this page but it will not work.  All is get is for the first line to be indented about one "tab" space to the right, but the second line will not shift.  However, the first line's indent does not appear to be centered either.  Is it possible that the binding offset or the indentfirst package is interacting with this negatively?  All of the other pages seem to work just fine. Any help would be appreciated.  \documentclass[12pt, a4paper, twoside]{article} \usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry} \usepackage[T1]{fontenc} \usepackage{indentfirst} \begin{document} \pagestyle{empty} \vspace*{36 pt} {\centering \textbf{\emph{\Huge{Since I Saw You Last,\\There's a Change Upon You}}} } \end{document}
57111
\begin{figure}     %\centering         \begin{minipage}[h]{0.58\textwidth}         \centering         \includegraphics[scale=0.4,trim=12mm 15mm 12mm 15mm]{fig1}         \end{minipage}         \begin{minipage}[h]{0.38\textwidth}         \centering         \include{fig2}         \end{minipage} \end{figure}   I get the fig1 nicely placed in the center of the left side BUT fig2 'sank' at the bottom of the right side. I dont really know what's wrong with the code. Actually fig2 is a table which i store as a tex file with codes only, something like:  \begin{tabular}{|c|c|}     \hline     aa  &amp; bb  \\ \hline     0 &amp; 10 \\ \hline     1 &amp; 2 \\ \hline \end{tabular}   Hope someone will help me fix this. Thanks in advance.
13607
I have the following page (deadlink: http://www.workingstorage.com/Sample.htm ) that has a footer which I can't make sit at the bottom of the page. I want the footer to  stick to the window bottom when the page is short and the screen is not filled, and stay at the document end and move down as normal when there is more than a screenful of content (instead of overlapping the content).  The CSS is inherited and befuddles me. I can't seem to change it properly to put a minimum height on the content or make the footer go to the bottom.
57743
I am following through the exercises in BlenderBasics_4thEdition2011.pdf and have gotten to the section on texturing.  The book goes through the creation of a Lighthouse and now I am texturing it.  I want to have a closeup view of the roof of the lighthouse after partitioning it as the lesson describes on page 54.    In order to get a close up view I selected the roof and want to center the screen on the vertices of it so I pressed the Numpad . key.  When I do that the view zooms so that the roof is off the screen.    What am I am doing wrong?    I tried Ray's answer and was able to move the origin but pressing the Numpad . key still did not work.  The centering was still on the bottom of the lighthouse, as if the origin was still there.
78073
I need to put some text at the same height in my page, and I'm trying to do it with a minipage, but I'm not able to do it since they get centre-aligned.    This is the LaTeX for the figure I've uploaded:  \begin{minipage}[]{0.5\textwidth}     \begin{flushleft}         {\large \textit{Author}:\vspace*{0.5cm} \\          Me}     \end{flushleft} \end{minipage}% % \begin{minipage}[]{0.5\textwidth}     \begin{flushright}         {\large \textit{Supervisor}:\vspace*{0.5cm} \\          Him}\\         \vspace*{0.5cm}         {\large \textit{Advisor}:\vspace*{0.5cm} \\          Other Guy}     \end{flushright}     \end{minipage}%   Can you please explain me what I'm doing wrong?
69778
I'm designing a website for a rather unknown software company. The company likes the design but cannnot get along with our desicion to center their logo on the top of their page, although all the other elements are centered. Therefore a left aligned logo wouldn't look good. I know, it seems all UX studies prove them right, but positioning the logo in the center isn't a unpopular practice anymore.   Furthermore I think the way we read a website has adapted the last 10 years. Are there any studies about this topic that could help prove my point?  Thanks
64539
The output from the following script \documentclass{article} \usepackage{tikz} \usepackage{graphicx} \begin{document} \begin{tikzpicture}   \node(title)[text width = 0.25\textwidth, text height = 3 cm, draw]{title};   \end{tikzpicture} \end{document}  is  How can I vertically align the text in the node? Specifying the text depth as in \node(title)[text width = 0.25\textwidth, text height = 1cm, text depth = 1 cm, draw]{     title line 1\\     title line 2\\     title line 3};  Does not result in the text being vertically centred.
4829
I have a webpage with an elastic layout that changes its width if the browser window is resized.  In this layout there are headlines (h2) that will have a variable length (actually being headlines from blogposts that I don't have control over). Currently - if they are wider than the window - they are broken into two lines.  Is there an elegant, tested (cross-browser) solution - for example with jQuery - that shortens the innerHTML of that headline tag and adds "..." if the text would be too wide to fit into one line at the current screen/container width?
120546
&lt;html&gt;     &lt;head&gt;         &lt;style type="text/css"&gt;             div {                 border:1px solid #000;                 min-width: 50%;             }         &lt;/style&gt;     &lt;/head&gt;     &lt;body&gt;         &lt;div&gt;This is some text. &lt;/div&gt;     &lt;/body&gt; &lt;/html&gt;   I believe the div should be 50 percent of the page, unless, for some reason, the text inside the div makes it larger. However, the border around the div stretches across the entire page width. This occurs in both IE and Firefox.  Suggestions?
12330
There was , which I've tried. But there is one problem: the textarea doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the clientHeight value comes back as the full size of the textarea, not its contents.  The code from that page is below:  function FitToContent(id, maxHeight) {    var text = id &amp;&amp; id.style ? id : document.getElementById(id);    if ( !text )       return;     var adjustedHeight = text.clientHeight;    if ( !maxHeight || maxHeight &gt; adjustedHeight )    {       adjustedHeight = Math.max(text.scrollHeight, adjustedHeight);       if ( maxHeight )          adjustedHeight = Math.min(maxHeight, adjustedHeight);       if ( adjustedHeight &gt; text.clientHeight )          text.style.height = adjustedHeight + "px";    } }  window.onload = function() {     document.getElementById("ta").onkeyup = function() {       FitToContent( this, 500 )     }; }
114657
How do I get a div to automatically adjust to the size of the background I set for it without setting a specific height (or min-height) for it?