以使用网页三剑客html+css+js实现网页设计与制作,页面排版布局高端大气。
使用HTML+CSS页面布局设计,HTML+CSS+JS网页设计与制作摄影类个人网页,这是一个优质的个人网页制作。
凭借简约的设计风格、精湛的制作工艺,突破与创新的理念。
个人网站、个人博客、个人介绍、摄影作品、图片画廊展示等个人网站的设计与制作。
1、网站程序:主要使用网页三剑客html+css+javaScript实现网页设计与制作,完成网站的功能设计。制作适用于任何浏览器或设备的精美网站。
2、网站布局:主要采用浮动布局。兼容各大主流浏览器、显示效果稳定。
3、网站文件:网站系统文件种类包含html网页结构文件、css网页样式文件、js网页特效文件、images网页图片文件等。
4、网站素材:搜集或制作适合网页风格和尺寸的图片,追求优质视觉体验。
5、网页编辑:网页作品代码简单,可使用任意HTML编辑软件(如:Dreamweaver、HBuilder、Sublime 、Vscode 、Notepad++ 、Webstorm、Text 等任意编辑软件进行编辑修改等操作)。
6、网页效果预览:双击html文件或者拖拽html文件到浏览器打开,即可预览当前网页效果。
1、视觉设计:排版布局极简设计,优质的视觉体验等。
2、动效交互:幻灯效果、入场动画、按钮点击、视差功能、锚点功能、图片画廊功能、英文断行等。
<script src="https://lf3-cdn-tos.bytescm.com/obj/cdn-static-resource/tt_player/tt.player.js?v=20160723"></script>
(1)index.html:首页html;
(2)style:静态资源目录,存放css网页样式文件、js网页特效文件、images网页图片文件等;
其中:
(1)css文件夹:存放网页所有css样式表文件文件;
(2)images文件夹:存放网页所有图片资源文件;
(3)js文件夹:存放网页所有网页特效文件;
全栈攻城狮-每日更新原创IT编程技术及日常实用视频。
主要内容:这是HTML课程的第五课,主要讲解HTML的图片和超链接。让自己设计的网页更加多元素。
在上节中主要讲解了HTML的文字标签和格式标签。上篇请戳→→04程序员定要学HTML,字体段落标签介绍,60秒搞定
其实如果没有记住也无所谓。毕竟这些标签都是HTML中比较常用的,在以后的相关的案例中也会使用。此系列教程主要讲解HTML从基础到精通。自己能够设计一个完整的前端网页项目。
程序员写代码
在HTML中添加图片其实很简单,就是添加一个img的标签。
图片标签的语法
一般有src、alt、width、height四种属性就够用了。
效果:
图片的显示效果
src表示的是图片的路径,这里面的值应该怎么写呢?
(1)html文件和图片在相同一个文件夹下。
HTML文件和图片文件在相同的目录下,可以直接书写文件的名称。
写文件名的写法,如上面的HTML
(2)图片在HTML文件所在目录的文件夹内:
如图:
图片文件在文件夹内
此时需要加上文件夹名称,并加上“/”表示下层目录:
下层目录的图片写法
(3)图片文件在上层目录
如果图片在HTML文件所在的上层目录,则需要写“..”表示向上一级。如图:
上层目录
超链接就是可以链接到某个资源的东西,比如我们打开百度首页搜索后,产生的就是超链接:
这些蓝字超链接
这些蓝色的文字标题,我们点击之后可以跳转到新的网站。这就是超链接。下面我们自己写一个超链接:
超链接的写法
超链接预览
超链接中的潮涌属性包括:href(网页地址)、title(说明描述)、target(打开网页的位置)、name(名称)。
其中href支持带有任何协议的连接。title是对超链接的说明。
程序员
target包括四个值:
_blank
在新的窗口打开连接
_self
在当前窗口打开超链接
_parent
在父窗口打开超链接,这个后面会说,不常用
_top
在整个窗口中打开被链接文档。
每天一个知识点,带你迈向软件编程大神,一起努力吧。
最近再做一个需求,需要对网页生成预览图,如下图
但是网页千千万,总不能一个个打开,截图吧;于是想着能不能使用代码来实现网页的截图。其实要实现这个功能,无非就是要么实现一个仿真浏览器,要么调用系统浏览器,再进行截图操作。
void startPrintScreen(ScreenShotParam requestParam)
{
Thread thread = new Thread(new ParameterizedThreadStart(do_PrintScreen));
thread.SetApartmentState(ApartmentState.STA);
thread.Start(requestParam);
if (requestParam.Wait)
{
thread.Join();
FileInfo result = new FileInfo(requestParam.SavePath);
long minSize = 1 * 1024;// 太小可能是空白圖,重抓
int maxRepeat = 2;
while ((!result.Exists || result.Length <= minSize) && maxRepeat > 0)
{
thread = new Thread(new ParameterizedThreadStart(do_PrintScreen));
thread.SetApartmentState(ApartmentState.STA);
thread.Start(requestParam);
thread.Join();
maxRepeat--;
}
}
}
2、模拟浏览器WebBrowser
void do_PrintScreen(object param)
{
try
{
ScreenShotParam screenShotParam = (ScreenShotParam)param;
string requestUrl = screenShotParam.Url;
string savePath = screenShotParam.SavePath;
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(requestUrl);
logger.Debug("wb.Navigate");
DateTime startTime = DateTime.Now;
TimeSpan waitTime = new TimeSpan(0, 0, 0, 10, 0);// 10 second
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
if (DateTime.Now - startTime > waitTime)
{
wb.Dispose();
logger.Debug("wb.Dispose() timeout");
return;
}
}
wb.Width = screenShotParam.Left + screenShotParam.Width + screenShotParam.Left; // wb.Document.Body.ScrollRectangle.Width (避掉左右側的邊線);
wb.Height = screenShotParam.Top + screenShotParam.Height; // wb.Document.Body.ScrollRectangle.Height;
wb.ScrollBarsEnabled = false;
wb.Document.Body.Style = "overflow:hidden";//hide scroll bar
var doc = (wb.Document.DomDocument) as mshtml.IHTMLDocument2;
var style = doc.createStyleSheet("", 0);
style.cssText = @"img { border-style: none; }";
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
logger.Debug("wb.Dispose()");
bitmap = CutImage(bitmap, new Rectangle(screenShotParam.Left, screenShotParam.Top, screenShotParam.Width, screenShotParam.Height));
bool needResize = screenShotParam.Width > screenShotParam.ResizeMaxWidth || screenShotParam.Height > screenShotParam.ResizeMaxWidth;
if (needResize)
{
double greaterLength = bitmap.Width > bitmap.Height ? bitmap.Width : bitmap.Height;
double ratio = screenShotParam.ResizeMaxWidth / greaterLength;
bitmap = Resize(bitmap, ratio);
}
bitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Gif);
bitmap.Dispose();
logger.Debug("bitmap.Dispose();");
logger.Debug("finish");
}
catch (Exception ex)
{
logger.Info($"exception: {ex.Message}");
}
}
3、截图操作
private static Bitmap CutImage(Bitmap source, Rectangle section)
{
// An empty bitmap which will hold the cropped image
Bitmap bmp = new Bitmap(section.Width, section.Height);
//using (Bitmap bmp = new Bitmap(section.Width, section.Height))
{
Graphics g = Graphics.FromImage(bmp);
// Draw the given area (section) of the source image
// at location 0,0 on the empty bitmap (bmp)
g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);
return bmp;
}
}
private static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return ResizeProcess(originImage, originImage.Width, originImage.Height, width, height);
}
public static string ScreenShotAndSaveAmazonS3(string account, string locale, Guid rule_ID, Guid template_ID)
{
//新的Template
var url = string.Format("https://xxxx/public/previewtemplate?showTemplateName=0&locale={0}&inputTemplateId={1}&inputThemeId=&Account={2}",
locale,
template_ID,
account
);
var tempPath = Tools.GetAppSetting("TempPath");
//路徑準備
var userPath = AmazonS3.GetS3UploadDirectory(account, locale, AmazonS3.S3SubFolder.Template);
var fileName = string.Format("{0}.gif", template_ID);
var fullFilePath = Path.Combine(userPath.LocalDirectoryPath, fileName);
logger.Debug("userPath: {0}, fileName: {1}, fullFilePath: {2}, url:{3}", userPath, fileName, fullFilePath, url);
//開始截圖,並暫存在本機
var screen = new Screen();
screen.ScreenShot(url, fullFilePath);
//將截圖,儲存到 Amazon S3
//var previewImageUrl = AmazonS3.UploadFile(fullFilePath, userPath.RemotePath + fileName);
return string.Empty;
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PrintScreen.Common
{
public class Screen
{
protected static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public void ScreenShot(string url, string path
, int width = 400, int height = 300
, int left = 50, int top = 50
, int resizeMaxWidth = 200, int wait = 1)
{
if (!string.IsOrEmpty(url) && !string.IsOrEmpty(path))
{
ScreenShotParam requestParam = new ScreenShotParam
{
Url = url,
SavePath = path,
Width = width,
Height = height,
Left = left,
Top = top,
ResizeMaxWidth = resizeMaxWidth,
Wait = wait != 0
};
startPrintScreen(requestParam);
}
}
void startPrintScreen(ScreenShotParam requestParam)
{
Thread thread = new Thread(new ParameterizedThreadStart(do_PrintScreen));
thread.SetApartmentState(ApartmentState.STA);
thread.Start(requestParam);
if (requestParam.Wait)
{
thread.Join();
FileInfo result = new FileInfo(requestParam.SavePath);
long minSize = 1 * 1024;// 太小可能是空白圖,重抓
int maxRepeat = 2;
while ((!result.Exists || result.Length <= minSize) && maxRepeat > 0)
{
thread = new Thread(new ParameterizedThreadStart(do_PrintScreen));
thread.SetApartmentState(ApartmentState.STA);
thread.Start(requestParam);
thread.Join();
maxRepeat--;
}
}
}
void do_PrintScreen(object param)
{
try
{
ScreenShotParam screenShotParam = (ScreenShotParam)param;
string requestUrl = screenShotParam.Url;
string savePath = screenShotParam.SavePath;
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(requestUrl);
logger.Debug("wb.Navigate");
DateTime startTime = DateTime.Now;
TimeSpan waitTime = new TimeSpan(0, 0, 0, 10, 0);// 10 second
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
if (DateTime.Now - startTime > waitTime)
{
wb.Dispose();
logger.Debug("wb.Dispose() timeout");
return;
}
}
wb.Width = screenShotParam.Left + screenShotParam.Width + screenShotParam.Left; // wb.Document.Body.ScrollRectangle.Width (避掉左右側的邊線);
wb.Height = screenShotParam.Top + screenShotParam.Height; // wb.Document.Body.ScrollRectangle.Height;
wb.ScrollBarsEnabled = false;
wb.Document.Body.Style = "overflow:hidden";//hide scroll bar
var doc = (wb.Document.DomDocument) as mshtml.IHTMLDocument2;
var style = doc.createStyleSheet("", 0);
style.cssText = @"img { border-style: none; }";
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
logger.Debug("wb.Dispose()");
bitmap = CutImage(bitmap, new Rectangle(screenShotParam.Left, screenShotParam.Top, screenShotParam.Width, screenShotParam.Height));
bool needResize = screenShotParam.Width > screenShotParam.ResizeMaxWidth || screenShotParam.Height > screenShotParam.ResizeMaxWidth;
if (needResize)
{
double greaterLength = bitmap.Width > bitmap.Height ? bitmap.Width : bitmap.Height;
double ratio = screenShotParam.ResizeMaxWidth / greaterLength;
bitmap = Resize(bitmap, ratio);
}
bitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Gif);
bitmap.Dispose();
logger.Debug("bitmap.Dispose();");
logger.Debug("finish");
}
catch (Exception ex)
{
logger.Info($"exception: {ex.Message}");
}
}
private static Bitmap CutImage(Bitmap source, Rectangle section)
{
// An empty bitmap which will hold the cropped image
Bitmap bmp = new Bitmap(section.Width, section.Height);
//using (Bitmap bmp = new Bitmap(section.Width, section.Height))
{
Graphics g = Graphics.FromImage(bmp);
// Draw the given area (section) of the source image
// at location 0,0 on the empty bitmap (bmp)
g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);
return bmp;
}
}
private static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return ResizeProcess(originImage, originImage.Width, originImage.Height, width, height);
}
private static Bitmap ResizeProcess(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
//using (Bitmap resizedbitmap = new Bitmap(width, height))
{
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
}
}
class ScreenShotParam
{
public string Url { get; set; }
public string SavePath { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Left { get; set; }
public int Top { get; set; }
/// <summary>
/// 長邊縮到指定長度
/// </summary>
public int ResizeMaxWidth { get; set; }
public bool Wait { get; set; }
}
}
完成,达到预期的效果。
*请认真填写需求信息,我们会在24小时内与您取得联系。