Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

meta name="viewport" is ignored by browser(?)

previously in <HEAD> it was

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

As you can see issue in screenShots that I have attached below.. there was issue of UI break so then I have updated <HEAD> with following code

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width; initial-scale=0.9; maximum-scale=0.9; minimum-scale=0.9;" />

But Still issue is there

Web page works well with resolution of 1280 X 800 as you can look at this image

enter image description here

these 3 columns (with black vertical line separated) are the <td> inside that a container with fixed width in px, and I cant change it to % due to some limitations. only main container have width : 100%, (Main container: with full page width behind all page content-with white BG)

I have attached screen shots of issues with screen resolution

On 1024 X 768

enter image description here

As you can see On browser with ratio 1024 X 768 "mobile image" is going beyond White box(Main container)

on 1920 X 1080

enter image description here

Here browser ratio is 1920 X 1080 and main container (White box) is 100% of width but those three columns (<TD>) are not, all three width remains same as previous images and main container is 100%

Update: Code link https://jsfiddle.net/p6x6jsgt/3/

like image 448
Chandrakant Avatar asked Aug 11 '16 12:08

Chandrakant


2 Answers

The problem is not your meta viewport tag. After having read all the comments here are a couple solutions to your problem:

A non-optimal solution:

Keep the table layout, change to percentage widths and use text blocks with white-space:nowrap; and <br> hard-coded line breaks with different font sizes depending on device screen size.

- About the layout:

Your .preview-panel has a fixed width in rem. To solve this, make the following changes:

.preview-panel {
    background-size:100% auto;
    width:100%;
}

Now you will notice layout issues with the other td. That's because you have to set them to percentage widths, for example:

.template-editor {
    width:100%;
}
.template-editor td {
    width:33%;
}

- About the text blocks:

You said setting widths to percentages would mess up your text blocks. Well, unfortunately there's no magical solution for this and all you can do about it (with your current layout) is to add this to whatever text block you put in there:

.foo {
    white-space:nowrap;
}

You would also have to fix your line breaks with <br> like so:

Lorem ipsum dolor sit amet,<br>
consectetur adipiscing elit.<br>
Fusce pulvinar aliquet luctus.

You could make the line breaks responsive if you wanted to, with something like (HTML):

<span class="line-break"></span>

(CSS):

.line-break {
    display:block;
}

Then you'd have the opportunity to set different font sizes on your media queries, and you could also hide the purposeful line-breaks with display:none;. This is, in my opinion, a better solution than plain old <br>.

With this, your layout should look better in all devices. That being said, this is still a poor solution and an entirely different approach is necessary, in my opinion.

A better solution:

Use flex or maybe just floated items, but not a table when your layout essentially is not a table. You have three panels, why would you forcefully use a table layout for that? Here's an example with flex:

.container {
  display:flex;
  align-items:stretch;
  justify-content:center;
}
.container__panel {
  flex-grow:1;
  height:600px;
  border:1px solid black;
}
<div class="container">
  <div class="container__panel"></div>
  <div class="container__panel"></div>
  <div class="container__panel"></div>
</div>

Disclaimer: the weird container__panel is BEM notation: http://getbem.com/introduction/

like image 84
fnune Avatar answered Oct 11 '22 05:10

fnune


Add

td{
    width: 33%;
}

For dividing the columns equally ,

Remove width css from the below class so that it can adjust width according to parent class (i have commented the code which i have removed from css)

  #cardListHolder {
        padding-top: 0.4375rem;
        /*width: 21.5625rem;*/
    }

 .edit-card .inner {
        margin: auto;
        padding: 0 2.1875rem;
    /*  width: 18.75rem;*/
    }
.preview-panel {
        background: rgba(0, 0, 0, 0) url("http://cdnsq.ur-nl.com/assets/mobile-898fc89b167945138c3d9f551a5ce551.png") no-repeat scroll center 0;
        height: 26.25rem;
        margin: auto;
        padding: 3.4375rem 0.8125rem 0;
     /* width: 13.3125rem;*/
    }

Just try replacing this whole css with your css. I hope this will fix your issue.

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    ul {
        list-style: outside none none;
        margin: 0;
    }

    .sectional-content {
        background: #f6f6f6;
        color: #222;
        cursor: auto;
        font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
        font-style: normal;
        font-weight: normal;
        line-height: 1.5;
        margin: 0;
        padding: 0;
        position: relative;
    }

    .wrapper {
        min-height: 100%;
        position: relative;
    }

    .centered-container {
        margin-left: auto;
        margin-right: auto;
        width: 96.6667%;
        padding-left: 0.3125rem;
        padding-right: 0.3125rem;
        position: relative;
    }

    .tabs-content {
        background: #fff none repeat scroll 0 0;
        border: 1px solid red;
        margin-top: -1px;
        padding: 1.5625rem;
        margin-bottom: 0;
        width: 100%;
    }

    .divider1 {
        height: 18px;
    }

    .template-editor {
        background: #fff none repeat scroll 0 0;
        border: 0 none;
        margin-bottom: 1.25rem;
        table-layout: auto;
    }

    .template-editor tr {
        background: transparent none repeat scroll 0 0 !important;
    }

    td{
        width: 33%;
    }

    .add-remove-template,
    .edit-card {
        padding-top: 5px !important;
        vertical-align: top;
    }

    .add-remove-template {
        border-left: 0 none;
        padding-left: 0 !important;
        padding-right: 0 !important;
        vertical-align: top;
    }

    table tr th,
    table tr td {
        color: #222;
        font-size: 0.875rem;
        padding: 0.5625rem 0.625rem;
        text-align: left;
    }

    #cardListHolder {
        padding-top: 0.4375rem;
    }

    .preview-template,
    .edit-card {
        border-left: 2px solid #808285;
        padding: 0 1.875rem !important;
        vertical-align: top;
    }

    .edit-card .inner {
        margin: auto;
        padding: 0 2.1875rem;
    }

    .preview-panel {
        background: rgba(0, 0, 0, 0) url("http://cdnsq.ur-nl.com/assets/mobile-898fc89b167945138c3d9f551a5ce551.png") no-repeat scroll center 0;
        height: 26.25rem;
        margin: auto;
        padding: 3.4375rem 0.8125rem 0;
    }
like image 41
Hamza Dairywala Avatar answered Oct 11 '22 04:10

Hamza Dairywala