如何在调整浏览器窗口大小时防止表格和图像元素移动[REPOST](How to prevent the table and image elements from moving when resizing browser window [REPOST])
我之前发布了一个问题并对其进行了编辑,但编辑后的版本并未显示正确的代码,因此我正在重新发布它。 当我调整我的浏览器窗口大小时,图像似乎走出了“框”或它的容器。 我是编码方面的初学者,我知道如果我使用div而不是table,但是这是为了实践目的(而且我需要它用于学校项目,我想这就是我想如何使用表格元素)。 无论如何,请帮我弄清楚该怎么做/如何修复代码。
编辑:当我调整大小时看起来像这样 。
.post { padding: 3em 3em 1em 3em; background: #ffffff; border: solid 1px rgba(160, 160, 160, 0.3); margin: 0 0 3em 0; position: relative; } .post>header { display: flex; border-bottom: solid 1px rgba(160, 160, 160, 0.3); left: -3em; margin: -3em 0 3em 0; position: relative; width: calc(100% + 6em); } .post>header .title { flex-grow: 1; flex: 1; padding: 3.75em 3em 3.3em 3em; } .post>header .title h2 { font-weight: 900; font-size: 1.5em; text-align: center; } .post>header .title> :last-child { margin-bottom: 0; } .image { width: 200px; height: 260px; } table { margin-left: auto; margin-right: auto; } td { padding: 10px; } .group { margin-left: auto; margin-right: auto; }
<article class="post"> <header> <div class="title"> <h2><a href="#">Favorite Books</a></h2> </div> </header> <table> <tr> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> </tr> </table> </article>
I previously posted a question and edited it but the edited version does not show the correct code so I'm reposting it. When I resize my browser window, the images seem to go out of the "box" or it's container. I'm a beginner at coding and I know it's much better if I use div instead of table, but this is for practice purposes (and also, I need it for a school project and I figured that's how I want to use the table element). Anyways, please help me figure out what to do/ how to fix the code.
EDIT: Looks like this when I resize.
.post { padding: 3em 3em 1em 3em; background: #ffffff; border: solid 1px rgba(160, 160, 160, 0.3); margin: 0 0 3em 0; position: relative; } .post>header { display: flex; border-bottom: solid 1px rgba(160, 160, 160, 0.3); left: -3em; margin: -3em 0 3em 0; position: relative; width: calc(100% + 6em); } .post>header .title { flex-grow: 1; flex: 1; padding: 3.75em 3em 3.3em 3em; } .post>header .title h2 { font-weight: 900; font-size: 1.5em; text-align: center; } .post>header .title> :last-child { margin-bottom: 0; } .image { width: 200px; height: 260px; } table { margin-left: auto; margin-right: auto; } td { padding: 10px; } .group { margin-left: auto; margin-right: auto; }
<article class="post"> <header> <div class="title"> <h2><a href="#">Favorite Books</a></h2> </div> </header> <table> <tr> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> <td> <a href="#" target="_blank"><img src="#" alt="#" class="image" /> </a> </td> </tr> </table> </article>
原文:https://stackoverflow.com/questions/42929745
最满意答案
天真的做法有多贵?
该条件大约需要1 ns,而
* 1000L
大约需要3 ns。 所以总共大约4 ns。 如果你每秒这样做2.5亿次,你就会遇到问题。 几千秒我不会担心。有没有更快的方法处理这个?
我确信这是你在性能方面的问题。 我会使用CPU并测量问题所在而不是猜测。
How expensive is the naive approach?
The condition will take about 1 ns and the
* 1000L
will take about 3 ns. So about 4 ns in total. If you do this 250 million times per second, you have a problem. A few thousand a second I wouldn't worry about.Is there any faster way of handling this?
I am sure it is the lease of your problems in terms of performance. I would use a CPU and measure where your problem are instead of guessing.
相关问答
更多-
在Python 3中,这可以分两步完成: 将时间字符串转换为datetime对象 将datetime对象的时间戳乘以1000,将其转换为毫秒。 例如像这样: from datetime import datetime dt_obj = datetime.strptime('20.12.2016 09:38:42,76', '%d.%m.%Y %H:%M:%S,%f') millisec = dt_obj.timestamp() * 1000 prin ...
-
int timeToGrow = 1352364; int secs = timeToGrow % 60; int mins = (timeToGrow / 60) % 60; int hours = ((timeToGrow / 60) / 60) % 24; int days = (((timeToGrow / 60) / 60) / 24) % 7; int weeks = (((timeToGrow/60)/60)/24)/7; System.out.println(weeks + " Weeks ...
-
问题出在这里的代码块中: long timeMilli = timeSeconds * 1000; this.calendar = Calendar.getInstance(); this.calendar.setTimeInMillis(timeMilli*1000); 你将时间乘以两倍; 删除* 1000的一个,你应该很好去:) The problem is in this block of code here: long timeMilli = timeSeconds ...
-
使用构造函数。 new Timestamp(System.currentTimeMillis()) http://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html#Timestamp(long) Use constructor. new Timestamp(System.currentTimeMillis()) http://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html ...
-
java将timestamp(以秒为单位)转换为时间戳(以毫秒为单位)(java convert timestamp in seconds to timestamp in milliseconds)[2023-02-02]
天真的做法有多贵? 该条件大约需要1 ns,而* 1000L大约需要3 ns。 所以总共大约4 ns。 如果你每秒这样做2.5亿次,你就会遇到问题。 几千秒我不会担心。 有没有更快的方法处理这个? 我确信这是你在性能方面的问题。 我会使用CPU并测量问题所在而不是猜测。 How expensive is the naive approach? The condition will take about 1 ns and the * 1000L will take about 3 ns. So about 4 ... -
使用EXTRACT功能。 SELECT EXTRACT(SECOND FROM TO_TIMESTAMP(P_REQUEST_TIME)-TO_TIMESTAMP(P_RESPONSE_TIME)) diff_seconds FROM
; Use EXTRACT function. SELECT EXTRACT(SECOND FROM TO_TIMESTAMP(P_REQUEST_TIME)-TO_TIMESTAMP(P_RESPONSE_TIME)) diff_seconds F ... -
FreeMarker 2.3.17为此推出了?number_to_date , ?number_to_time和?number_to_datetime 。 请参阅: http : //freemarker.org/docs/ref_builtins_expert.html#ref_builtin_numToDate 您还需要设置日期/时间格式和区域; 请参阅http://fmpp.sourceforge.net/settings.html#sect17 可能你必须升级FMPP中的FreeMarker。 为此 ...
-
将毫秒转换为时间戳(Convert milliseconds to Timestamp)[2022-08-19]
如果向timestamp添加interval ,则会获得timestamp (请参阅日期/间隔算术 )。 正如Benoit注意到的那样 ,当超过大约2.1e9时,你不能指定一个秒的间隔: SQL> SELECT numtodsinterval(2.2e9, 'SECOND'), 2 numtodsinterval(2.3e9, 'SECOND') 3 FROM dual; NUMTODSINTERVAL(2.2E9,'SECOND' NUMTODSINTERVAL(2.3E ... -
将时间戳以毫秒转换为python中的datetime(Converting timestamp with milliseconds to datetime in python)[2023-11-11]
日期时间可以是微秒(1微秒= 1000纳秒)您可以为您的示例执行以下操作: dt = datetime.fromtimestamp(1092847621L).replace(microsecond = 7100000L/1000) Datetimes can have microseconds (1 microsecond = 1000 nanoseconds) You can do the following for your example: dt = datetime.fromtimes ... -
NSNumber NSDate的时间戳(以毫秒为单位)[重复](NSNumber timestamp in milliseconds to NSDate [duplicate])[2023-05-09]
尝试这个: NSTimeInterval seconds = [aNumber doubleValue] / 1000; NSDate *date = [NSDate dateWithTimeIntervalSince1970:seconds]; Try this: NSTimeInterval seconds = [aNumber doubleValue] / 1000; NSDate *date = [NSDate dateWithTimeIntervalSince1970:seconds];