This my code: codesandbox.io
CSS
#media (width > 736px) {
#LogoMonni-mobile {
display: none;
}
}
#media (max-width <= 736px) {
#LogoMonni-pc {
display: none;
}
#LogoMonni-mobile {
display: block;
}
}
JSX
import { ReactComponent as LogoMonniPC } from "./logoMonniPC.svg";
import { ReactComponent as LogoMonniMobile } from "./LogoMonniMobile.svg";
import "./styles.css";
export default function App() {
return (
<div className={"LogoMonni"}>
<LogoMonniPC />
<LogoMonniMobile />
</div>
);
}
When the screen size is > 736px I show the computer version of the SVG, and when <= 736px I show the mobile version, but for some reason <LogoMonniMobile /> does not appear on the screen. What is the reason and how can this be fixed?
You cant use logical operators like <.
#media screen and (min-width: 737px) {
#LogoMonni-mobile {
display: none;
}
}
#media screen and (max-width: 736px) {
#LogoMonni-pc {
display: none;
}
#LogoMonni-mobile {
display: block;
}
}
As i understand the id problem LogoMonni_0 LogoMonni_1 LogoMonni_2 ... if id sv1 are the same as scg2 I don’t know for some reason the browser thinks they should disappear
Hi I have a script which works fine for resizing a logo on scroll down and back again, but i dont want it to do it when the screen size is less than 600px how do i alter to achieve this any help greatly appreciated.
// When the user scrolls down 50px from the top of the document, resize the header's font size
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
document.getElementById("header-logo").style.width = "180px";
}
else {
document.getElementById("header-logo").style.width = "215px";
}
}
You could do something like
if (screen.width > 600px){
//your code
}
You can use media queries to achieve this
#media (max-width: 600px) {
#header-logo {
width: 180px !important;//!important use to override inner html styles
}
}
with a bit of luck and using some of DoomBots code got it to work with the below
// When the user scrolls down 50px from the top of the document, resize the header's font size
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50 ||
screen.width < 600) {
document.getElementById("header-logo").style.width = "180px";
}
else {
if (screen.width > 600){
document.getElementById("header-logo").style.width = "215px";
}
}
}
I have a couple of SVG that get rendered like this
export const MenuHeaderTab = (props: RenderableProps<Props>) =>
{
const css = props.isActive ? "menu-tab menu-tab-selected" : "menu-tab";
return (
<div onClick={() => props.onClick()} className={css}>
{props.children}
</div>
)
}
the problem i have is that in desktop mode it works fine cause they render in the order that i want them to. the problem is that in mobile portrait mode i want one of the rendered SVG to be first in the order (row). So i thought i use row and just set the className on the SVG
so here is the sass/css
#media all and (orientation: portrait)
{
.menu-tab {
width: 10%;
height: 20%;
margin-left: 4vw;
}
.menu-close-button {
order: -1;
}
.menu-leaderboard-button {
order: 2;
}
.menu-prize-button {
order: 3;
}
.menu-rules-button {
order: 4;
}
so i even provided order to all the SVG and -1 to the one that should be first, but they all stay in the exact same order still. Anyone have any clue why this happens.
Order attribute only works if the father element use display: flex
Assuming the .menu-tab is the father's div of this elements .menu-close-button, .menu-leaderboard-button, .menu-prize-button, .menu-rules-button, you just need to set a display: flex to the .menu-tab
Bellow follow an example of the code:
Look athe the close button, its the last element but how its set -1 as order, it become the first element
.menu-tab {
width: 10%;
height: 20%;
margin-left: 4vw;
display: flex;
}
.menu-tab a{
margin-right: 10px;
}
.menu-close-button {
order: -1;
}
.menu-leaderboard-button {
order: 2;
}
.menu-prize-button {
order: 3;
}
.menu-rules-button {
order: 4;
}
<div class="menu-tab">
leaderboard
Prize
Rules
Close
</div>
I'm having an issue with JWP7, when the player is loading on portrait or landscape mode it stretches out to the full window as expected, but when changing the device orientation while the player is still playing, the player doesn't scaling the the new window dimensions.
Code example:
$('.player').height($window.height());
jwplayer("myElement").setup({
file: "somevideo.mp4",
width: windows.width,
height: windows.height,
});
<div id="player">
<div class="close_btn fadeIn"><img src="/img/close.png" width="50" /> </div>
<div id='player_frame'>
<iframe id=""video_iframe></iframe>
</div>
</div>
#media screen and (orientation:portrait) {
.video_iframe
{
height: 100vh;
overflow: hidden;
width: 100vw;
}
}
#media screen and (orientation:landscape) {
.video_iframe
{
height: 100vh;
width: 100vw;
}
}
Any suggestions?
Thank you all in advance.
There appear to be a few problems with your code:
1) The iframe ID attribute is not correctly enclosed with quotes:
<iframe id=""video_iframe></iframe>
should be:
<iframe id="video_iframe"></iframe>
2) Your CSS selectors are targeting using the class notation rather than by the element ID:
.video_iframe
{
height: 100vh;
overflow: hidden;
width: 100vw;
}
should be:
#video_iframe
{
height: 100vh;
overflow: hidden;
width: 100vw;
}
3) The "player" wrapper is likely to be restricting the height of the generated video player as the following is only being run once, and is probably setting an explicit pixel value:
$('#player').height($window.height());
Try removing this line.
I managed to fixed it with jQuery mobile - orientation change event:
$(window).bind( 'orientationchange', function(e){
var windowHeight = $(window).height() + 'px';
var windowWidth = $(window).width() + 'px';
if(window.orientation == 0) // Portrait
{
$("#myElement").height(windowHeight);
$("#myElement").width(windowWidth);
}
else // Landscape
{
$("#myElement").height(windowHeight);
$("#myElement").width(windowWidth);
}
});
I have this, but I feel 4 is too big for my sidebar width and 3 is too small (it has to add up to 12).
<div class="col-md-8">
<div class="col-md-4">
I tried this but it doesn't work:
<div class="col-md-8.5">
<div class="col-md-3.5">
Is there another way to get a similar outcome?
Thanks for your help!
To expand on #isherwood's answer, here is the complete code for creating custom -sm- widths in Bootstrap 3.3
In general you want to search for an existing column width (say col-sm-3) and copy over all the styles that apply to it, including generic ones, over to your custom stylesheet where you define new column widths.
.col-sm-3half, .col-sm-8half {
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
#media (min-width: 768px) {
.col-sm-3half, .col-sm-8half {
float: left;
}
.col-sm-3half {
width: 29.16666667%;
}
.col-sm-8half {
width: 70.83333333%;
}
}
For a 12 columns grid, if you want to add half of a column (4,16667%) to each column width. This is what you do.
For example, for col-md-X, define .col-md-X-5 with the following values.
.col-md-1-5 { width: 12,5%; } // = 8,3333 + 4,16667
.col-md-2-5 { width: 20,83333%; } // = 16,6666 + 4,16667
.col-md-3-5 { width: 29,16667%; } // = 25 + 4,16667
.col-md-4-5 { width: 37,5%; } // = 33,3333 + 4,16667
.col-md-5-5 { width: 45,83333%; } // = 41,6667 + 4,16667
.col-md-6-5 { width: 54,16667%; } // = 50 + 4,16667
.col-md-7-5 { width: 62,5%; } // = 58,3333 + 4,16667
.col-md-8-5 { width: 70,83333%; } // = 66,6666 + 4,16667
.col-md-9-5 { width: 79,16667%; } // = 75 + 4,16667
.col-md-10-5 { width: 87,5%; } // = 83,3333 + 4,16667
.col-md-11-5 { width: 95,8333%; } // = 91,6666 + 4,16667
I rounded certain values.
Secondly, to avoid copying css code from the original col-md-X, use them in the class declaration. Be careful that they should be added before your modified ones. That way, only the width gets override.
<div class="col-md-2 col-md-2-5">...</div>
<div class="col-md-5">...</div>
<div class="col-md-4 col-md-4-5">...</div>
Finally, don't forget that the total should not exceed 12 columns, which total 100%.
I hope it helps!
You could certainly create your own classes:
.col-md-3point5 {width: 28.75%}
.col-md-8point5 {width: 81.25%;}
I'd do this before I'd mess with the default columns. You may want to use those inside these.
You'd probably also want to put those inside a media query statement so that they only apply for larger-than-mobile screen sizes.
Bootstrap 4.1+ version of Antoni's answer:
The Bootstrap mixin is now #include make-col($size, $columns: $grid-columns)
.col-md-8half {
#include make-col-ready();
#include media-breakpoint-up(md) {
#include make-col(8.5);
}
}
.col-md-3half {
#include make-col-ready();
#include media-breakpoint-up(md) {
#include make-col(3.5);
}
}
Source:
Official documentation
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
You can use Bootstrap's own column mixins make-xx-column():
.col-md-8half {
.make-md-column(8.5);
}
.col-md-3half {
.make-md-column(3.5);
}
you can customize bootstrap stylesheet, as in:
.col-md-8{
width: /*as you wish*/;
}
Then, set the media query for that too, as in:
#media screen and (max-width:768px){
.col-md-8{
width:99%;
}
}