0

I need some css help.You can see that if you click to add another hexagon on the right side, I want it to overflow to the right. It is jumping down to create a new row. How can I get it to overflow with a scroll x?

Here is the css.

#flow {
    width: 600px;
    height: 250px;
    overflow-x: scroll;
}

2 Answers 2

2

This is probably not the most elegant solution, but it seems to do the trick. http://jsfiddle.net/L6pke/5/

#container {
    width: 500px;
    height: 250px;
    overflow-x: auto;
}
#flow {
    width: 800px;
    height:100%;
}

And in your JS code, you update the width of the flow div every time you add an element.

var flow = document.getElementById('flow'),
           current_width = flow.clientWidth;
flow.style.width = current_width + 104 + 'px';
Sign up to request clarification or add additional context in comments.

1 Comment

So I ended up using ng-style in 'flow' to make it a little more angular like this. ng-style="setWidth()", and in the controller $scope.setWidth = function() { return {width: $scope.things.length * 135 + "px"};} It works great. Thanks again.
0

Try this:

#flow {
    width: 550px;
    height: 250px;
    overflow-x: scroll;
}

.hex {
    display: inline-block;
    margin-left:3px;
    margin-bottom:-26px;
    text-align:center;
    color:#fff;
    font-size:1.1rem
}

.hex-row {
    clear:left;
    white-space: nowrap;
}

basically:

Make .hex display as inline-block, better than floating for this, besides, with floating it wouldn't work because floating removes from normal flow.

Remove width in .hex-row to make it automatic, and add white-space: nowrap to it to remove wrapping.

http://jsfiddle.net/zargyle/L6pke/3/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.