图片文字模拟漫画书的布局效果

栏目: Html · 发布时间: 5年前

核心属性

display: flex + justify-content: space-between + align-items: center 图片居中水平排列

border-image 图片和文字的动画边框效果

@media 根据不同的页面大小,图片呈现不同的布局方式

相关知识

CSS3 border-image详解、应用及jQuery插件

  1. <base href="https://pics.codecolor.cn/graphic-novel/">
  2. <div id="strip">
  3. <figure id="panel1">
  4. <img src="pleading-man.jpg" alt="A photograph of a man kneeling in a parking garage, pleading for his life">
  5. <figcaption>“等等…”</figcaption>
  6. </figure>
  7. <img src="car-strip.jpg" alt  id="panel2">
  8. <figure id="panel3">
  9. <img src="gunman.jpg" alt="A backlit photograph of a man holding a gun">
  10. <figcaption>砰!!!</figcaption>
  11. </figure>
  12. </div>
  1. #strip {
  2. display: flex;
  3. justify-content: space-between;
  4. align-items: center;
  5. max-width: 820px;
  6. margin: 0 auto;
  7. }
  8. #strip img {
  9. border-image: url(https://pics.codecolor.cn/graphic-novel/comic-frame.png) 22 16 16 22;
  10. background: #000;
  11. border-width: 12px;
  12. border-style: solid;
  13. }
  14. #panel1 {
  15. width: 40%;
  16. position: relative;
  17. }
  18. #panel3 {
  19. width: 35%;
  20. position: relative;
  21. }
  22. #panel1 img, #panel3 img {
  23. width: 100%;
  24. }
  25. #strip figcaption {
  26. position: absolute;
  27. top: 2rem;
  28. right: -2rem;
  29. padding: 1rem;
  30. background: #fff;
  31. background-clip: padding-box;
  32. font-size: 1.2rem;
  33. font-family: Comic Sans MS, Comic Sans, cursive;
  34. border-image: url(https://pics.codecolor.cn/graphic-novel/lettering-frame.png) 11 10 14 12;
  35. border-width: 6px;
  36. border-style: solid;
  37. }
  38. #panel1 figcaption {
  39. letter-spacing: .3rem;
  40. top: 1rem;
  41. right: -4rem;
  42. }
  43. #panel3 figcaption {
  44. left: -2rem;
  45. width: 4rem;
  46. font-style: italic;
  47. }
  48. @media screen and (max-width: 60rem) {
  49. #panel2 {
  50. display: none;
  51. }
  52. #strip img {
  53. width: 100%;
  54. }
  55. #panel1 figcaption {
  56. top: -1rem;
  57. }
  58. }
  59. @media screen and (max-width: 50rem) {
  60. #panel1 figcaption {
  61. top: 10rem;
  62. }
  63. }
  64. @media screen and (max-width: 30rem) {
  65. #strip {
  66. flex-direction: column;
  67. }
  68. #panel1 {
  69. order: 3;
  70. }
  71. #panel1,#panel3 {
  72. width: 60%;
  73. }
  74. #panel3 {
  75. align-self: flex-end;
  76. }
  77. #panel3 figcaption {
  78. display: none;
  79. }
  80. }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

同伦方法纵横谈

同伦方法纵横谈

王则柯 / 大连理工大学 / 2011-5 / 25.00元

《走向数学丛书07-同伦方法纵横谈》,在本书里读者会看到许多人物故事,作为一本普及读物,我们有时候甚至觉得,对于不少读者来说,书中所写的科学研究中的人物故事,可能比书中介绍的具体的研究成果更有价值,这些人物故事,许多都出自我们个人之间的交往,这是从一个侧面了解科学研究的规律,了解科学家之成为科学家的珍贵记录。一起来看看 《同伦方法纵横谈》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具