简体   繁体   English

制作 header 和带有文本响应的图片?

[英]Make a header and picture with text responsive?

When I adjust my browser to the size of a cell phone to check everything, the sentences on the image overlap.当我将浏览器调整为手机大小以查看所有内容时,图像上的句子重叠。 In addition, the elements in the header also shift.此外,header 中的元素也会发生偏移。 How can I prevent this?我怎样才能防止这种情况?

https://i.stack.imgur.com/kMIPP.jpg https://i.stack.imgur.com/kMIPP.jpg

You haven't added any code so iam not sure what is wrong but my guess is that your font size is constant so i recommend that you use responsive font-size if thats the problem link您尚未添加任何代码,因此我不确定出了什么问题,但我猜您的字体大小是恒定的,因此如果那是问题 链接,我建议您使用响应式字体大小

Needed knowledge需要的知识

The CSS line-height property is responsible for this text effect. CSS line-height 属性负责此文本效果。 You can find more here CSS line-height你可以在这里找到更多CSS line-height

If you want to be in control of what resolution your browser uses in a given style, check out this tutorial on CSS media-query如果您想控制浏览器在给定样式中使用的分辨率,请查看CSS 媒体查询上的本教程

How to do it?怎么做?

  1. Add a breakpoint for phone resolution using media-query使用media-query为电话解析添加breakpoint

  2. Add a property line-height to your header将属性line-height添加到您的 header

  3. Reload the page in the browser and reduce the window size.在浏览器中重新加载页面并减小 window 大小。 Now the text should be displayed without overlapping.现在应该显示文本而不重叠。

     @media only screen and (max-width: 768px) { /* For mobile phones: */.header-class-name { width: 100%; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM