我该如何创建这样的平铺系统?

时间:2017-01-18 12:07:04

标签: css html5 css3 flexbox

Container with Tiles

所以我正在创建一个 响应网站 ,其中我想要一个像上面图片中的平铺系统。不幸的是,我无法正确完成它。

这是我现在的ATTEMPT。使用Flexbox



.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;
  width: 100%;
  height: 30px;
  display: -webkit-box;
  display: -moz-inline-box;
  display: -ms-inline-flexbox;
  display: -webkit-inline-flex;
  display: inline-flex;
  -moz-justify-content: space-around;
  -ms-justify-content: space-around;
  justify-content: space-around;
  -webkit-flex-flow: row wrap;
  -moz-flex-flow: row wrap;
  flex-flow: row wrap;
}
.flex-item {
  background: #eaeaea;
  padding: 5px;
  width: 130px;
  height: 90px;
  margin-top: 0px;
  margin-left: 0px;
  color: black;
  font-weight: bold;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.flex-item:hover {
  background: #d9d9d9;
}
.flex-item-stop {
  background: crimson;
  padding: 5px;
  width: 130px;
  height: 90px;
  margin-top: 0px;
  color: black;
  font-weight: bold;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.flex-item-stop:hover {
  background-color: #bb1133;
}
#Menue {
  position: fixed;
  left: 0;
  height: 25%;
  width: 650px;
  float: right;
  padding: 25px 0;
  margin: -25px 0;
  display: inline-flex;
  display: -moz-inline-flex;
  display: -webkit-inline-flex;
  justify-content: space-around;
  -moz-justify-content: space-around;
  -webkit-justify-content: space-around;
  flex-flow: column wrap;
  -moz-flex-flow: column wrap;
  -webkit-flex-flow: column wrap;
}

<div id="Menue">
  <div class="flex-container">
    <div class="flex-item">Vanilla</div>
    <div class="flex-item">Citrus</div>
    <div class="flex-item">Bananasplit</div>
    <div class="flex-item">Gum</div>
  </div>
  <div class="flex-container" style="margin-top:10%;">
    <div class="flex-item">Sweden</div>
    <div class="flex-item">Austria</div>
    <div class="flex-item">Russia</div>
    <div class="flex-item">Brazil</div>
  </div>
  <div class="flex-container" style="margin-top:10%;">
    <div class="flex-item">Positiv</div>
    <div class="flex-item">Negativ</div>
    <div class="flex-item">Neutral</div>
    <div class="flex-item-stop">&nbsp;</div>
  </div>
</div>
&#13;
&#13;
&#13;

我只是不能创建瓷砖之间的间距,我的结果在不同的浏览器中似乎有所不同,特别是在Internet Explorer 11中。
我还想拥有的是,在singel中应该总是有4个瓷砖&#34;线&#34;这有可能吗?

现在我的问题是:在我的代码中我究竟需要改变什么来完成这样的平铺系统? Flexbox的替代品是什么?

赞赏任何示例建议。

2 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情:

&#13;
&#13;
.row{
display:table;
content:'';
clear:both;
width:100%;
}
.item{
box-sizing:border-box;
width:25%;
border:1px solid white;
height:100px;
background-color:yellow;
float:left;
text-align:center;
}
&#13;
<div class="row">
<div class="item">Vanilla</div>
<div class="item">Gum</div>
<div class="item">Citrus</div>
<div class="item">BananaSplit</div>
</div>
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

给这个破解:

<强> HTML

@Configuration
public class ConfigLocal {

    @Value("${https.proxyHost}")
    private String proxyHost;

    @Value("${https.proxyPort}")
    private Integer proxyPort;

    @Value("${https.proxyUser}")
    private String proxyUser;

    @Value("${https.proxyPassword}")
    private String proxyPassword;

    @Bean
    public OAuth2RestTemplate oauth2RestTemplate(ClientCredentialsResourceDetails clientCredentialsResourceDetails)
            throws KeyManagementException, KeyStoreException, NoSuchAlgorithmException {
        OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);

        // Instanciate a new http client with proxy configuration, and bypass SSL Certificate verification
        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
        credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(proxyUser, proxyPassword));

        HttpClientBuilder httpClientBuilder =
                HttpClients.custom()
                        .setProxy(new HttpHost(proxyHost, proxyPort))
                        .setDefaultCredentialsProvider(credentialsProvider)
                        .setSSLHostnameVerifier(new NoopHostnameVerifier())
                            .setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, (x509Certificates, s) -> true)
                                    .build());

        // requestFactory
        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
        ClientCredentialsAccessTokenProvider clientCredentialsAccessTokenProvider = new ClientCredentialsAccessTokenProvider();
        clientCredentialsAccessTokenProvider.setRequestFactory(requestFactory);

        // accessTokenProvider
        AccessTokenProvider accessTokenProvider = new AccessTokenProviderChain(Arrays.<AccessTokenProvider> asList(
                new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(),
                new ResourceOwnerPasswordAccessTokenProvider(), clientCredentialsAccessTokenProvider));

        restTemplate.setAccessTokenProvider(accessTokenProvider);

        return restTemplate;
    }
}

<强> CSS

<div class="container">
    <div class="inner-block"></div>
    <div class="inner-block"></div>
    <div class="inner-block"></div>
    <div class="inner-block"></div>
    <div class="inner-block"></div>
    <!-- e.t.c... !-->
</div>

JsFiddle https://jsfiddle.net/r4w1v0dm/2/