Only have scrolling on X axis


Only have scrolling on X axis



So i'm trying to make a box in which if the content is to big, it only scrolls on the X. I have tried every stack overflow way i have seen, and can't find a answer after days that works.



Here is my HTML:


<div class="outputElement">
<div class="xOutput" style="border-bottom: 1px solid black;"><h1 class="algbra-h1">X: 10432323232323232323232323232323232323232322</h1></div>
<div class="yOutput" style=""><h1 class="algbra-h1">X: 10432323232323232323232323232323232323232322</h1></div>
</div>



CSS:


.outputElement {
background-color: #f5f1ef;
width: 226px;
margin-left: 3%;
border: 1px solid black;
height: 80px;
}

.xOutput,.yOutput{
vertical-align:top;
text-align: center;
}
.xOutput {
overflow-x: scroll;
height: 40px;
}
.yOutput {
width: 226px;
overflow-x: scroll;
font-size: 30px;
}

.algbra-h1 {
font-size: 30px;
}



Now here is what happens when a long number is in the box:



https://postimg.cc/image/5phnvjiot/



Just encase you want to, the project i am using this on is -->



Line 72 HTML & Line 219-243 CSS



https://codepen.io/Mike-was-here123/pen/QrdJdO



It jumps down a line on the Y-axis, then scrolls on the X. Note that its the same thing in both of those boxes. Its two div's onto of each other, inside of a main div.



Here is what i need:



It only to scroll on the X-axis, it cannot jump down a line then scroll.



Here is what i tried:



Making the Y-hidden --> Just hides it, doesn't prevent it, Anything else amounts to the same outcome.





Setting a fixed height on the youtput and xoutput is causing the problem as the text overflows but is hidden behind the cutoff. I'm working on a solution....
– www139
Jun 30 at 18:29




1 Answer
1



Setting fixed pixel heights to the containing divs is causing the problem. Remove the fixed heights to allow all the text to be visible. The splitting between X and the number is caused by whitespace wrapping. When there isn't enough horizontal space for text, it is broken to the next line at the next whitespace character. The wrapping can be overridden with white-space:nowrap;.


white-space:nowrap;


.outputElement {
background-color: #f5f1ef;
width: 226px;
margin-left: 3%;
border: 1px solid black;
}

.yOutput {
width: 226px;
overflow-x: scroll;
font-size: 30px;
}

.xOutput {
overflow-x: scroll;
}

.algbra-h1 {
font-size: 30px;
white-space:nowrap;
}



I'm not sure what you want in the big picture but I did resolve the problem described in the question.



I tried to create a code snippet but things broke since the project seems to use a lot of external libraries. I have instead opted to fork the original codepen.



Note: forked, working example pen removed upon request.





My idea was to have it all on one line X: 4545454.... and it scroll over to see the rest of the number. Also dude can you please not copy the whole entire pen? Only copy the HTML code your working on.
– user9319687
Jun 30 at 23:53





Like copy the pen, then delete all the code except the HTML code above that you are working on.
– user9319687
Jul 1 at 0:04





Ok, I understand the affect you want. Use white-space:nowrap;. I forked the entire pen because, at the time, I wasn't sure if the JS was doing any work in setting up the interface of the calculator. Rather than reading through all the code irrelevant to the problem, I forked the entire thing. I would have created a snippet here on SO but your project has dependencies that I couldn't figure out in the snippet. Anyway, I removed JS from the pen and I figured out the answer to your problem.
– www139
Jul 1 at 18:40


white-space:nowrap;





Thanks dude. I show my projects off a little sometimes, and i didn't want someone searching it up and thinking i copied or something. Can you delete the pen too, since its figure it out. I don't mean it in any rude way. Thanks a lot dude :D
– user9319687
Jul 1 at 19:11





Ok. Gotcha. I do the same thing sometimes too :)
– www139
Jul 1 at 19:17






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

List of Kim Possible characters

Audio Livestreaming with Python & Flask

NSwag: Generate C# Client from multiple Versions of an API