css標簽resolution,html/css to fit all screen resolution

可以將文章內容翻譯成中文,廣告屏蔽插件可能會導致該功能失效(如失效,請關閉廣告屏蔽插件后再試):

問題:

I'm working on the website and I'm trying to make it responsive to all resolutions but without success..

Here is HTML:

Lorem ipsum nasov je?

"Lorem ipsum dolor sit amet, consectetur adipisicing elit."

And here is css:

body

{

width:1920px;

background-color: #f8e0b3;

height:1080px;

}

div.container

{

width:100%;

height:100%;

}

div.header

{

background:url(img/header.jpg);

width:100%;

height:46%;

margin-top:;

margin-left:;

border-bottom: 2px solid black;

}

h1.naslov

{

font-size:60px;

color:white;

margin:0 auto;

margin-left:28%;

font-family: Aramis;

}

p.naslov-text

{

font-size:40px;

color:#634ea9;

margin:0 auto;

width:1000px;

margin-top:0%;

margin-left:36%;

font-family: Aramis;

}

When I resize my browser website doesn't resize. I've been trying all morning and I'm really burnout. Do anyone know what logic to approach to make this fit all screens , but only using css.

回答1:

As you are giving a fixed width to your body and p.naslov-text, your website will not resize. Remove all px sizing and replace them with percentage values.

But if you want fixed sizes and also responsive you must use css media queries like that:

body

{

width:1920px;

background-color: #f8e0b3;

height:1080px;

}

@media screen and (min-width: 500px) {

body {

width:420px;

}

}

@media screen and (min-width: 800px) {

body {

width:720px;

}

}

回答2:

CSS:

#gallery-1 img {

width:375px;

}

@media screen and (min-width: 1366px) {

#gallery-1 img {width:375px;}

}

@media screen and (min-width: 1440px) {

#gallery-1 img {width:428px;}

}

@media screen and (min-width: 1600px) {

#gallery-1 img {width:434px;}

}

@media screen and (min-width: 1920px) {

#gallery-1 img {width:540px;}

}

Reference: Stack Over Flow

JQUERY:

Use jquery for resize window. This one is dynamic code for window resizing for all browsers.

Example code here using jquery:

$(document).ready(function(){

$(window).resize();

});

$(window).resize(function{

// your code

var windowWidth=$(window).width();

var mainContainerWidth=windowWidth-100; // For example

$("#yourMainContainer").css({"width":mainContainerWidth+"px"});

});

like that you will try for your main class width and height.

回答3:

You have a fixed width on your body

回答4:

Remove width (in "px") from body and also from p.naslov-text. Try to give width:100%; to get responsive layout Fiddle

CSS:

body {

background-color: #f8e0b3;

height:1080px;

width:100%;

}

p.naslov-text {

font-size:40px;

color:#634ea9;

margin:0 auto;

margin-top:0%;

margin-left:36%;

font-family: Aramis;

}

回答5:

Hope this helps..

FIDDLE

CSS

body

{

width:100%;

background-color: #f8e0b3;

height:100%;

}

div.container

{

width:100%;

height:100%;

}

div.header

{

background:url(img/header.jpg);

width:100%;

height:100%;

margin: 2% 2% 2% 2%;

border-bottom: 2px solid black;

}

h1.naslov

{

font-size:60px;

color:white;

margin:0 auto;

float:none;

font-family: Aramis;

}

p.naslov-text

{

font-size:40px;

color:#634ea9;

margin:0 auto;

margin-top:0%;

float:left;

font-family: Aramis;

}

Also try to use media Query for whatever resolution you want..

回答6:

hello you should use @media screen in your css and you should use % instead px.

@media screen and (min-width: 1366px) {

#gallery-1 img {width:375px;}

}

@media screen and (min-width: 1440px) {

#gallery-1 img {width:428px;}

}

@media screen and (min-width: 1600px) {

#gallery-1 img {width:434px;}

}

@media screen and (min-width: 1920px) {

#gallery-1 img {width:540px;}

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/456850.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/456850.shtml
英文地址,請注明出處:http://en.pswp.cn/news/456850.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

釘釘開發筆記(一)

釘釘開發分為:1、移動客戶端。2、PC端。3、服務端。三個平臺的開發。 1、移動端:面對釘釘手機用戶和企業用戶。 2、同上主要面向PC端的用戶和企業。 3、服務端,用于用戶和企業內部管理的平臺方向,例如OA網站。 本人主要從事移動端…

import導入模塊

面試題: import module與from module import * 兩種模塊導入有何區別 1. import module 引用共享變量時,要使用module.變量名,而from module import * 直接使用變量名即可 2. import module方式 本地不會創…

在啟動HDFS時,針對集群中namenode無法識別datanode的問題的解決方法

最近由于重裝了系統,需要對之前搭建的集群要做些改動。在對每個虛擬機的網絡進行正確的配置之后,重新執行hadoop/sbin/start-dfs.sh命令來啟動HDFS,然而namenode卻無法識別datanode。 后來通過對之前學過的知識進行回顧和梳理發現了問題的所…

HBase的基礎知識

1.HBase(NoSQL:不是關系型數據庫)的邏輯數據模型 HBase – Hadoop Database,是一個高可靠性、高性能、面向列、可伸縮的分布式存儲系統,利用HBase技術可在廉價PC Server上搭建起大規模結構化存儲集群。HBase利用Hadoop HDFS作為其文件存儲系統…

Django 部署基礎【使用 Nginx + uWSGI 的方式來部署來 Django】

本文主要講解在 Linux 平臺下,使用 Nginx uWSGI 的方式來部署來 Django,這是目前比較主流的方式。當然你也可以使用 Gunicorn 代替 uWSGI,不過原理都是類似的,弄懂了其中一種,其它的方式理解起來問題也不會很大。 有很…

css的屬性是變量是怎么表達,CSS自定義屬性(變量)

Github上有個叫electron-api-demos的項目,看代碼的時候發現了這么一個css文件(variables.css)::root {--color: hsl(0,0%,22%);--color-subtle: hsl(0,0%,44%);--color-strong: hsl(0,0%,11%);--color-link: hsl(0,0%,22%);--color-border: hsl(0,0%,88%…

Exception in thread main java.lang.UnsupportedClassVersionError的另類解決辦法

最近在Linux虛擬機上跑在windows平臺上的eclipes打出來的jar包時報出Exception in thread “main” java.lang.UnsupportedClassVersionError的錯誤: 經過上網查詢了解到是因為自己Windows使用的是jdk1.8版本,而Linux使用的是jdk1.7版本,所…

Linux命令【第一篇】

1、創建一個目錄/data 記憶方法:英文make directorys縮寫后就是mkdir。 命令: mkdir /data 或 cd /;mkdir data #提示:使用分號可以在一行內分割兩個命令。 實踐過程: 方法一: [rootoldboy66 ~]# mkdir /data #查…

Jenkins + gitlab webhook實現自動化部署

1、先在Jenkins安裝插件Gitlab Hook Plugin 和Build Authorization Token Root Plugin;2.插件安裝完成后在任務里添加token3、在gitlab上添加鉤子4、點擊測試鉤子或push代碼再看Jenkins已經在構建了就說明成功了(也可以在瀏覽器直接執行這個URL&#xff…

多繼承以及MRO順序【super().的使用】

多繼承以及MRO順序 1. 單獨調用父類的方法 # codingutf-8print("******多繼承使用類名.__init__ 發生的狀態******") class Parent(object):def __init__(self, name):print(parent的init開始被調用)self.name nameprint(parent的init結束被調用)class Son1(Paren…

人工智能專業詞匯集

最近看到一篇關于AI專業詞匯總結的文章,感覺不錯,分享一下。 對應的詞匯項目地址為:https://github.com/jiqizhixin/Artificial-Intelligence-Terminology 本詞匯庫目前擁有的專業詞匯共計 500 個,主要為機器學習基礎概念和術語…

js 當前日期增加自然月

js 在日期不滿足的情況下就會自動加1個月,比如在當前時間為3月31號,傳入1,1兩個參數,預期結果為2月29日,但是結果輸出了3月2日。就是如果不滿就會溢出到下個月,后來看了api發現了setMonth有兩個方法&#x…

好雨云幫如何對接Git Server

前言 云幫目前支持對接GitLab、Gogs、Github,或者主流代碼托管平臺的公開項目,后期會考慮接入其他類型的Git服務。 私有云 GitLab是一個用于倉庫管理系統的開源項目,私有云服務里使用比較多的自建Git服務。 對接GitLab 通過應用市場進行安裝Gitlab 安裝G…

Python 生成requirement 使用requirements.txt

python項目中必須包含一個 requirements.txt 文件,用于記錄所有依賴包及其精確的版本號。以便新環境部署。requirements.txt可以通過pip命令自動生成和安裝生成requirements.txt文件 pip freeze > requirements.txt安裝requirements.txt依賴 pip install -r requ…

Source Insight上手教程

目錄Project的建立和工作區域同步查看定義查找引用查找調用Source Insight常用快捷鍵 目錄 最近剛參加工作,第一個任務就是查看項目的源碼,熟悉代碼結構。于是乎就簡單學習了Source Insight。在這里就轉載別人的文章當做自己的筆記,便于自己…

微信禁用右上角的分享按鈕,WeixinJSBridge API以及隱藏分享的子按鈕等菜單項

今天在做隱藏微信右上角的分享按鈕 百度查到的一串代碼&#xff0c;挺好用的 <!--禁用微信分享按鈕--><script>function onBridgeReady() {WeixinJSBridge.call(hideOptionMenu);}if (typeof WeixinJSBridge "undefined") {if (document.addEventListen…

python2.7無法使用pip(安裝easy_install)

python27和python36 共存時安裝pip方法&#xff0c;解決python27文件夾下沒有script文件方法 報錯&#xff1a; D:\PYTHON2.7>python ez_setup.py Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg Traceback (most recent call…

Codeforces 754E:Dasha and cyclic table

Codeforces 754E&#xff1a;Dasha and cyclic table 題目鏈接&#xff1a;http://codeforces.com/problemset/problem/754/E 題目大意&#xff1a;$A$矩陣&#xff08;$size(A)n \times m$&#xff0c;僅含a-z&#xff09;在整個平面做周期延拓&#xff0c;問$B$矩陣&#xff…

位運算中的左移和右移的計算詳解

最近在學習javaScrapt&#xff0c;在學到位運算符這部分的時候&#xff0c;突然發現看不懂書上的例子了。經過查找資料后&#xff0c;發現了一遍不錯的文章。分享一下&#xff1a; 正數的左移和右移 以3為例 3的二進制為 00000011 右移2位的時候將最右的11去掉左邊補00結果…

AC日記——字符串P型編碼 openjudge 1.7 31

31:字符串p型編碼 總時間限制: 1000ms內存限制: 65536kB描述給定一個完全由數字字符&#xff08;0,1,2,…,9&#xff09;構成的字符串str&#xff0c;請寫出str的p型編碼串。例如&#xff1a;字符串122344111可被描述為"1個1、2個2、1個3、2個4、3個1"&#xff0c;因…