我想使用htmland創建拆分頁面css,但不幸的是它在另一個之下。
@import url('https://fonts.googleapis.com/css?family=Open Sans:300,400,800');
@media (min-width: 500px) {
.col-sm-6 {
width: 50%;
}
}
html, body {
height: 100%;
min-height: 18em;
}
.frontend-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-code.png");
}
.uiux-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-post-its.png");
}
.split-pane {
padding-top: 1em;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
height: 50%;
min-height: 9em;
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
font-weight:300;
;
}
@media(min-width: 500px) {
.split-pane {
padding-top: 2em;
height: 100%;
}
}
.split-pane > div {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
text-align: center;
}
.split-pane > div .text-content {
line-height: 1.6em;
margin-bottom: 1em;
}
.split-pane > div .text-content .big {
font-size: 2em;
}
.split-pane > div img {
height: 1.3em;
}
@media (max-width: 500px) {
.split-pane > div img {
display:none;
}
}
.split-pane button, .split-pane a.button {
font-family: 'Open Sans', sans-serif;
font-weight:800;
background: none;
border: 1px solid white;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
width: 15em;
padding: 0.7em;
font-size: 0.5em;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
text-decoration: none;
color: white;
display: inline-block;
cursor: pointer;
}
.split-pane button:hover, .split-pane a.button:hover {
text-decoration: none;
background-color: white;
border-color: white;
cursor: pointer;
}
.uiux-side.split-pane button:hover, .split-pane a.button:hover {
color: violet;
}
.frontend-side.split-pane button:hover, .split-pane a.button:hover {
color: blue;
}
#split-pane-or {
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
text-align: center;
width: 100%;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@media (max-width: 925px) {
#split-pane-or {
top:15%;
}
}
#split-pane-or > div img {
height: 2.5em;
}
@media (max-width: 500px) {
#split-pane-or {
position: absolute;
top: 50px;
}
#split-pane-or > div img {
height:2em;
}
}
@media(min-width: 500px) {
#split-pane-or {
font-size: 3em;
}
}
.big {
font-size: 2em;
}
#slogan {
position: absolute;
width: 100%;
z-index: 100;
text-align: center;
vertical-align: baseline;
top: 0.5em;
color: white;
font-family: 'Open Sans', sans-serif;
font-size: 1.4em;
}
@media(min-width: 500px) {
#slogan {
top: 5%;
font-size: 1.8em;
}
}
#slogan img {
height: 0.7em;
}
.bold {
text-transform:uppercase;
}
.big {
font-weight:800;
}
<head>
<title>Wybierz Swój Maraton! </title>
<link rel ="stylesheet" href="/wybierzmaraton.css" />
</head>
<div class='split-pane col-xs-12 col-sm-6 uiux-side'>
<div>
<img src='myContent1.png.png'>
<div class='text-content'>
<div class="bold">YOU WANT</div>
<div class='big'>MARATON MATURZYSTY?</div>
</div>
<button>
KLIKNIJ
</button>
</div>
</div>
<div class='split-pane col-xs-12 col-sm-6 frontend-side'>
<div>
<img src='myContent.png'>
<div class='text-content'>
<div class="bold">YOU WANT</div>
<div class='big'>this?</div>
</div>
<a class='button'>
KLIKNIJ
</a>
</div>
</div>
<div id='split-pane-or'>
<div>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/bcr-white.png'>
</div>
</div>
效果是我將這些 div 放在另一個之下。

如何更改并正確制作?我也嘗試使用此鏈接中的自定義形狀,但我只得到空白。 垂直分屏自定義形狀
我從這個網站 https://speckyboy.com/snippets-split-screen-layouts/得到它
uj5u.com熱心網友回復:
默認情況下,您的 DIV 是“塊”,這意味著它們的寬度是 100%,并且您不能將兩個 div 并排放置。解決此問題的方法是使用 CSS FLEX顯示屬性,我強烈建議您觀看 Youtube 視頻,因為如果您真正看到元素如何放置它們,就會更容易理解。
簡而言之,在元素上使用“display: flex”意味著他們的子元素將根據自己的寬度嘗試適應一行或多行。還有一些其他的 CSS 屬性可以幫助你以你想要的方式定位你的 div。在您的情況下,您只想將兩個元素放在同一行上,因此一個簡單的解決方案可能是添加一個新的 div 來包裝您的兩個現有 div 并使其具有彈性,因此您將看到您正在獲得 2 個 div同一行
@import url('https://fonts.googleapis.com/css?family=Open Sans:300,400,800');
@media (min-width: 500px) {
.col-sm-6 {
width: 50%;
}
}
html, body {
height: 100%;
min-height: 18em;
}
.frontend-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-code.png");
}
.uiux-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-post-its.png");
}
.split-pane {
padding-top: 1em;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
height: 50%;
min-height: 9em;
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
font-weight:300;
;
}
@media(min-width: 500px) {
.split-pane {
padding-top: 2em;
height: 100%;
}
}
.split-pane > div {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
text-align: center;
}
.split-pane > div .text-content {
line-height: 1.6em;
margin-bottom: 1em;
}
.split-pane > div .text-content .big {
font-size: 2em;
}
.split-pane > div img {
height: 1.3em;
}
@media (max-width: 500px) {
.split-pane > div img {
display:none;
}
}
.split-pane button, .split-pane a.button {
font-family: 'Open Sans', sans-serif;
font-weight:800;
background: none;
border: 1px solid white;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
width: 15em;
padding: 0.7em;
font-size: 0.5em;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
text-decoration: none;
color: white;
display: inline-block;
cursor: pointer;
}
.split-pane button:hover, .split-pane a.button:hover {
text-decoration: none;
background-color: white;
border-color: white;
cursor: pointer;
}
.uiux-side.split-pane button:hover, .split-pane a.button:hover {
color: violet;
}
.frontend-side.split-pane button:hover, .split-pane a.button:hover {
color: blue;
}
#split-pane-or {
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
text-align: center;
width: 100%;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@media (max-width: 925px) {
#split-pane-or {
top:15%;
}
}
#split-pane-or > div img {
height: 2.5em;
}
@media (max-width: 500px) {
#split-pane-or {
position: absolute;
top: 50px;
}
#split-pane-or > div img {
height:2em;
}
}
@media(min-width: 500px) {
#split-pane-or {
font-size: 3em;
}
}
.big {
font-size: 2em;
}
#slogan {
position: absolute;
width: 100%;
z-index: 100;
text-align: center;
vertical-align: baseline;
top: 0.5em;
color: white;
font-family: 'Open Sans', sans-serif;
font-size: 1.4em;
}
@media(min-width: 500px) {
#slogan {
top: 5%;
font-size: 1.8em;
}
}
#slogan img {
height: 0.7em;
}
.bold {
text-transform:uppercase;
}
.big {
font-weight:800;
}
.div-flex {
/* And this is your new CSS Class */
display: flex
}
<div class='div-flex'> <!-- This is your new DIV -->
<div class='split-pane col-xs-12 col-sm-6 uiux-side'>
<div>
<img src='myContent1.png.png'>
<div class='text-content'>
<div class="bold">YOU WANT</div>
<div class='big'>MARATON MATURZYSTY?</div>
</div>
<button>
KLIKNIJ
</button>
</div>
</div>
<div class='split-pane col-xs-12 col-sm-6 frontend-side'>
<div>
<img src='myContent.png'>
<div class='text-content'>
<div class="bold">YOU WANT</div>
<div class='big'>this?</div>
</div>
<a class='button'>
KLIKNIJ
</a>
</div>
</div>
</div>
<div id='split-pane-or'>
<div>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/bcr-white.png'>
</div>
</div>
uj5u.com熱心網友回復:
看來您已經在使用 Bootstrap。因此,在這種情況下,我建議使用兩個col-6's 來拆分頁面。見下文。
img {
width: 100%;
}
.frontend-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-code.png");
background-size: cover;
background-repeat: no-repeat;
height: 100vh;
}
.uiux-side {
background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/74452/website-post-its.png");
background-size: cover;
background-repeat: no-repeat;
height: 100vh;
}
.col-6 {
padding: 0 !important;
}
body {
overflow-x: hidden;
}
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-6">
<div class="uiux-side"></div>
</div>
<div class="col-6">
<div class="frontend-side"></div>
</div>
</div>
</body>
編輯?我添加了您background-images在 div 上使用的實際影像并設定了背景屬性,以便它們顯示全高。col-6默認情況下會給你半個半寬度,但為了讓它看起來每一邊都在使用50vw你必須添加padding: 0 !important;覆寫引導程式在 col 上的默認填充。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/421766.html
標籤:
上一篇:使YouTube視頻嵌入回應式
下一篇:引導工具提示未在徽章上觸發
