У меня есть приведенный ниже код, который я пытаюсь сделать отзывчивым, и я не могу понять, как сохранить изображение профиля справа на FlexBox. Теперь col-md-auto
находится слева, и я хочу, чтобы он был справа, как только сработает мобильный телефон.
На больших экранах он справа, но как только я нажимаю на мобильный, он нажимает col-md-auto
слева, а я бы хотел оставить его справа.
Любая помощь будет принята с благодарностью!
Пожалуйста, нажмите «Выполнить фрагмент» .
/* Core */
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
text-align: left;
background: #fff;
background-size: auto;
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
margin-left: 0;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
-webkit-text-decoration-skip: objects;
}
a:-webkit-any-link {
color: -webkit-link;
cursor: pointer;
text-decoration: underline;
}
body .jupiterx-site {
font-family: "Roboto", sans-serif;
font-size: 1rem;
color: #212529;
}
[type=search] {
outline-offset: -2px;
-webkit-appearance: none;
}
input, button {
overflow: visible;
}
input, button {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button {
-webkit-appearance: button;
}
button {
border-radius: 0;
}
button {
text-transform: none;
}
/* Header */
header, nav {
display: block;
}
@media (min-width: 768px) {
.jupiterx-navbar-desktop-left {
text-align: left;
}
.navbar-expand-md {
-ms-flex-flow: row nowrap;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
flex-flow: row nowrap;
-webkit-box-pack: flex-start;
-ms-flex-pack: flex-start;
justify-content: flex-start;
}
.navbar-expand-md > .container {
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
}
.jupiterx-navbar-desktop-left .jupiterx-navbar-brand {
margin-right: 1rem;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
/* Top Navigation - Right Side */
.navbar-expand-md .navbar-collapse {
display: -webkit-box!important;
display: -ms-flexbox!important;
display: flex!important;
-ms-flex-preferred-size: auto;
flex-basis: auto;
}
.jupiterx-navbar-desktop-left .jupiterx-search-form {
margin-left: 1rem;
}
.col-md {
-ms-flex-preferred-size: 0;
flex-basis: 0;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
max-width: 100%;
}
.col-md-auto {
-ms-flex: 0 0 auto;
-webkit-box-flex: 0;
flex: 0 0 auto;
width: auto;
max-width: none;
}
}
@media (max-width: 767.98px) and (min-width: 576px) {
.jupiterx-navbar-tablet-left {
text-align: left;
}
}
@media (min-width: 576px) {
.form-inline .form-control {
display: inline-block;
width: auto;
vertical-align: middle;
}
}
.navbar {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: space-between;
-ms-flex-pack: space-between;
justify-content: space-between;
}
.navbar > .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: space-between;
-ms-flex-pack: space-between;
justify-content: space-between;
}
.navbar-light .navbar-brand {
color: whitesmoke;
font-weight: bold;
}
.navbar-brand {
display: inline-block;
padding-top: .3125rem;
padding-bottom: .3125rem;
margin-right: 1rem;
font-size: 1.25rem;
line-height: inherit;
white-space: nowrap;
}
/* Top navigation */
.jupiterx-header {
position: relative;
z-index: 100;
width: 100%;
}
.jupiterx-site-navbar {
padding-top: .30rem;
padding-bottom: .30rem;
-webkit-transition: padding .15s;
transition: padding .15s;
background-color: #2f689f;
}
.jupiterx-site-navbar > div {
-ms-flex-direction: row;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
flex-direction: row;
}
.jupiterx-site-navbar .jupiterx-navbar-brand-link {
margin-right: 0;
text-decoration: none;
}
.container {
width: 100%;
padding-right: 20px;
padding-left: 20px;
margin-right: auto;
margin-left: auto;
max-width: 1140px;
}
/* Top Navigation - Right Side */
.jupiterx-site-navbar .navbar-collapse {
-ms-flex-direction: inherit;
-webkit-box-orient: inherit;
-webkit-box-direction: inherit;
flex-direction: inherit;
-webkit-box-pack: flex-end;
-ms-flex-pack: flex-end;
justify-content: flex-end;
}
.collapse:not(.show) {
display: none;
}
.navbar-collapse {
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.jupiterx-site-navbar .jupiterx-search-form {
overflow: hidden;
}
.jupiterx-search-form {
position: relative;
}
.form-inline {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: row wrap;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
flex-flow: row wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.jupiterx-site-navbar .jupiterx-search-form .form-control {
border-style: solid;
border-radius: 4px;
width: 250px;
}
.jupiterx-search-form .form-control {
width: 100%;
padding-right: 2em;
}
.form-control {
display: block;
width: 100%;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
transition: border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
}
.btn:not(:disabled):not(.disabled) {
cursor: pointer;
}
.jupiterx-search-form button {
position: absolute;
right: 0;
top: 0;
color: #6c757d;
font-size: .875rem;
padding-top: .65rem;
background-color: transparent;
}
.btn {
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
-webkit-transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
}
.jupiterx-search-form button:before {
line-height: 0;
}
.jupiterx-icon-search-1:before {
font-family: "FontAwesome";
content: "\f002";
}
[class*=" jupiterx-icon-"]:before, [class^=jupiterx-icon-]:before {
/*font-family: jupiterx;*/
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-style: normal;
font-variant: normal;
font-weight: 400;
speak: none;
text-decoration: none;
text-transform: none;
line-height: 1;
}
::before {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* Bottom Header */
.sh-subheader {
padding-top: 1rem;
padding-bottom: 1rem;
background: whitesmoke;
background-size: auto;
border-top-width: 1px;
border-top-style: solid;
}
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-md, .col-md-auto {
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
/* Align items vertically */
.align-vertically {
display: flex;
align-items: center;
}
/* Circle profile picture on */
.sh-profile-picture {
width: 50px;
height: 50px;
max-width: 100%;
border-radius: 50%;
margin-right: 5px;
}
#mega-menu-wrap-secondary-menu #mega-menu-secondary-menu > li.mega-menu-item > a.mega-menu-link:first-child {
padding-left: 0px;
}
.sh-user-name {
color: #2f689f;
font-weight: bold;
}
#mega-menu-wrap-secondary-menu .mega-menu-toggle.mega-menu-open + #mega-menu-secondary-menu {
margin-top: 15px;
}
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php wp_head(); ?>
<script src="https://kit.fontawesome.com/f692c9923b.js" crossorigin="anonymous"></script>
</head>
<body <?php body_class(); ?>>
<div class="jupiterx-site">
<!-- Bottom banner -->
<header class="sh-header" role="banner" itemscope="itemscope" itemtype="http://schema.org/WPHeader">
<div class="sh-subheader">
<div class="container">
<div class="row">
<div class="col-md align-vertically">
<div class="jupiterx-subfooter-menu-container">
Menu
</div>
</div>
<div class="col-md-auto align-vertically">
<img class="sh-profile-picture" src="https://onedublin.files.wordpress.com/2010/10/penn-state-football-field.jpg" alt="profile picture">
<div class="sh-user-name"><?= $user->get_user_login(); ?></div>
</div>
</div>
</div>
</div>
</header>
</div>