Horizontal multi position

I am trying to create a multiscreen selection:

  • The height and width of each option is 100.
  • Parameters are listed horizontally.
  • The parameters should break the line if they do not match the width of the browsers .

Looks like for now: JSFiddle Demo

* {
    box-sizing: border-box;
}
#data {
    overflow:hidden;
    padding:0;
	width:100vw;
}
select {
	padding:0;
	padding-left:1px;
	border:none;
	background-color:#eee;
	width:100vw;
}
option {
	height:100px;
	width:100px;
	border:1px solid #000;
	background-color:white;
	margin-left:-1px;
	display:inline-block;
}
<form>
    <div id="data">
		<select multiple size="1">
			<option>1</option>
			<option>2</option>
			<option>3</option>
			<option>4</option>
    		<option>5</option>
			<option>6</option>
    		<option>7</option>
			<option>8</option>
			<option>9</option>
			<option>10</option>
			<option>11</option>
			<option>12</option>
		</select>
	</div>
</form>
Run code

The only thing that is missing now is a line break.

I hope you can help! :)

+4
source share
3 answers

You can simply use the usual way of inserting line breaks in text. For tags , the default <select>style white-spaceis changed to nowrap, so all you have to do is change it to normal:

* {
    box-sizing: border-box;
}
#data {
    overflow:hidden;
    padding:0;
	width:100vw;
}
select {
	padding:0;
	padding-left:1px;
	border:none;
	background-color:#eee;
	width:100vw;
	white-space: normal;
	height:200px;
}
option {
	height:100px;
	width:100px;
	border:1px solid #000;
	background-color:white;
	margin-left:-1px;
	display:inline-block;
}
<form>
<div id="data">
	<select multiple size="1">
		<option>1</option>
		<option>2</option>
		<option>3</option>
		<option>4</option>
		<option>5</option>
		<option>6</option>
		<option>7</option>
		<option>8</option>
		<option>9</option>
		<option>10</option>
		<option>11</option>
		<option>12</option>
	</select>
</div>

</form>
Run code
+3

,

height:200px;

:

float: left;

Fiddle: http://jsfiddle.net/6hotLutu/2/

+1

Hi, the following changes should do the trick

Remove overflow:hidden;from#data

add overflow:visible;toselect

and add float:left;in option.

+1
source

Source: https://habr.com/ru/post/1568368/


All Articles